code
stringlengths
31
1.39M
docstring
stringlengths
23
16.8k
func_name
stringlengths
1
126
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
166
url
stringlengths
50
220
license
stringclasses
7 values
public function testShouldGetArgsUsingAllExtraParams($param1, $param2): void { $this->assertSame([$param1, $param2], $this->test->testFunctionGetArgsAllExtra($param1, $param2)); }
@dataProvider getArgsDataProvider @param mixed $param1 @param mixed $param2
testShouldGetArgsUsingAllExtraParams
php
zephir-lang/zephir
tests/Extension/FcallTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/FcallTest.php
MIT
public function testShouldGetArgsUsingAllExtraParamsAndStaticFunction($param1, $param2): void { $this->assertSame([$param1, $param2], Fcall::testStaticFunctionGetArgsAllExtra($param1, $param2)); }
@dataProvider getArgsDataProvider @param mixed $param1 @param mixed $param2
testShouldGetArgsUsingAllExtraParamsAndStaticFunction
php
zephir-lang/zephir
tests/Extension/FcallTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/FcallTest.php
MIT
public function testValue($input, $expected, $has): void { $this->assertSame(self::$test->hasValue($input), $has); $this->assertSame(self::$test->getValue($input), $expected); }
@dataProvider fieldProvider @param mixed $input @param mixed $expected @param mixed $has
testValue
php
zephir-lang/zephir
tests/Extension/FetchTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/FetchTest.php
MIT
public function testShouldCorrectDetectestExistenceWithPassedName(string $func): void { $this->assertTrue($this->test->testWithPassedName($func)); }
@dataProvider providerInternalFunctions @issue https://github.com/zephir-lang/zephir/issues/1547 @param string $func The internal (built-in) function name
testShouldCorrectDetectestExistenceWithPassedName
php
zephir-lang/zephir
tests/Extension/FunctionExistsTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/FunctionExistsTest.php
MIT
public function testShouldCorrectDetectestExistenceInsideTheZephirCode(): void { $expected = [ 'substr' => true, 'cubstr' => false, 'ucfirst' => true, 'bcfirst' => false, 'stripos' => true, 'ktripos' => false, 'trim' => true, 'prim' => false, ]; $this->assertSame($expected, $this->test->testBuiltInFunctions()); }
@issue https://github.com/zephir-lang/zephir/issues/1547
testShouldCorrectDetectestExistenceInsideTheZephirCode
php
zephir-lang/zephir
tests/Extension/FunctionExistsTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/FunctionExistsTest.php
MIT
public function testShouldCorrectDetectestExistenceByUsingString(): void { $this->assertTrue($this->test->testWithString()); }
@issue https://github.com/zephir-lang/zephir/issues/1547
testShouldCorrectDetectestExistenceByUsingString
php
zephir-lang/zephir
tests/Extension/FunctionExistsTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/FunctionExistsTest.php
MIT
public function testInstanceOf5(): void { $this->assertTrue($this->test->testInstanceOf5($this->test)); $this->assertFalse($this->test->testInstanceOf5(new \stdClass())); }
@issue https://github.com/zephir-lang/zephir/issues/776 @issue https://github.com/zephir-lang/zephir/issues/822
testInstanceOf5
php
zephir-lang/zephir
tests/Extension/InstanceOffTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/InstanceOffTest.php
MIT
public function testInstanceOf7(): void { $this->assertTrue($this->test->testInstanceOf7($this->test)); $this->assertFalse($this->test->testInstanceOf7(new \stdClass())); }
@issue https://github.com/zephir-lang/zephir/issues/1828
testInstanceOf7
php
zephir-lang/zephir
tests/Extension/InstanceOffTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/InstanceOffTest.php
MIT
public function testInstanceOf8(): void { $this->assertTrue($this->test->testInstanceOf8('\\Stub\\InstanceOff')); $this->assertFalse($this->test->testInstanceOf8('\\stdClass')); }
@issue https://github.com/zephir-lang/zephir/issues/1828
testInstanceOf8
php
zephir-lang/zephir
tests/Extension/InstanceOffTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/InstanceOffTest.php
MIT
public function testInstanceOf9(): void { $this->assertTrue($this->test->testInstanceOf9($this->test, '\\Stub\\InstanceOff')); $this->assertFalse($this->test->testInstanceOf9($this->test, '\\stdClass')); }
@issue https://github.com/zephir-lang/zephir/issues/1828
testInstanceOf9
php
zephir-lang/zephir
tests/Extension/InstanceOffTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/InstanceOffTest.php
MIT
public function testShouldCreateAnInstanceUsingMoreThan10Parameters(): void { $this->assertInstanceOf(Instance::class, Instance::testIssue1339()); }
@issue https://github.com/zephir-lang/zephir/issues/1339
testShouldCreateAnInstanceUsingMoreThan10Parameters
php
zephir-lang/zephir
tests/Extension/InstanceTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/InstanceTest.php
MIT
public function testCallAnonymousFunctionWithContext(): void { $test = new McallDynamic(); $this->assertSame('Caller:perform', $test->testCallAnonymousFunctionWithContext()); }
@issue https://github.com/zephir-lang/zephir/issues/1751
testCallAnonymousFunctionWithContext
php
zephir-lang/zephir
tests/Extension/MCallDynamicTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/MCallDynamicTest.php
MIT
public function testShouldReturnInstance(): void { $test = new McallInternal(); $this->assertInstanceOf(McallInternal::class, $test->issue1956()); }
@issue https://github.com/zephir-lang/zephir/issues/1956
testShouldReturnInstance
php
zephir-lang/zephir
tests/Extension/McallInternalTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/McallInternalTest.php
MIT
public function testIssue1136(): void { $test = new Mcall(); if (version_compare(PHP_VERSION, '8.0.0', '>=')) { $this->assertInstanceOf(\finfo::class, $test->issue1136()); } else { $this->assertIsResource($test->issue1136()); } }
@issue https://github.com/zephir-lang/zephir/issues/1136
testIssue1136
php
zephir-lang/zephir
tests/Extension/MCallTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/MCallTest.php
MIT
public function testShouldDinamicalyCreateInstancesInLoop(): void { $test = new Oo(); $this->assertSame( ['A', 'AA', 'B', 'BB'], $test->createInstancesInLoop() ); }
@issue https://github.com/zephir-lang/zephir/issues/1673
testShouldDinamicalyCreateInstancesInLoop
php
zephir-lang/zephir
tests/Extension/OoTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/OoTest.php
MIT
public function testCollectMatches(): void { $this->assertSame(['asd'], $this->test->testPregMatchSaveMatches('asd', '#asd#')); }
@issue https://github.com/zephir-lang/zephir/issues/287
testCollectMatches
php
zephir-lang/zephir
tests/Extension/PregmatchTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/PregmatchTest.php
MIT
public function testPregMatchAllFlags(): void { $arr = $this->test->testMatchAllInZep(); $this->assertSame($arr[0], [['test1', 'test2'], ['test1', 'test2']]); $this->assertSame($arr[1], [['test1', 'test1'], ['test2', 'test2']]); }
@issue https://github.com/zephir-lang/zephir/issues/144
testPregMatchAllFlags
php
zephir-lang/zephir
tests/Extension/PregmatchTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/PregmatchTest.php
MIT
public function testShouldRequireUsingNewSymbolTable(): void { ob_start(); $actual = $this->test->requireExternal3(__DIR__.'/../fixtures/require-me-3.php'); ob_end_clean(); $this->assertSame('test', $actual); }
@issue https://github.com/zephir-lang/zephir/pull/1428
testShouldRequireUsingNewSymbolTable
php
zephir-lang/zephir
tests/Extension/RequiresTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/RequiresTest.php
MIT
public function testShouldRenderTemplate(): void { $param = 1; $this->assertEquals( 2, $this->test->renderTemplate(__DIR__.'/../fixtures/template.php', ['a' => 2]) ); $this->assertEquals(1, $param); }
@issue https://github.com/zephir-lang/zephir/issues/1621
testShouldRenderTemplate
php
zephir-lang/zephir
tests/Extension/RequiresTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/RequiresTest.php
MIT
public function testShouldRequirePhar(): void { $this->assertEquals( "I'm in", $this->test->requireExternal1('phar://'.__DIR__.'/../fixtures/requires/myapp.phar/index.php') ); }
@issue https://github.com/zephir-lang/zephir/issues/1713
testShouldRequirePhar
php
zephir-lang/zephir
tests/Extension/RequiresTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/RequiresTest.php
MIT
public function testShouldReturnWithParameter(): void { $tester = new Returns(); $this->assertSame('Return back', $tester->returnWithParameter('Hello World!')); }
@issue https://github.com/zephir-lang/zephir/issues/1534
testShouldReturnWithParameter
php
zephir-lang/zephir
tests/Extension/ReturnsTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/ReturnsTest.php
MIT
public function testShouldReturnWithParameterStaticVersion(): void { $this->assertSame('Return back', Returns::returnWithParameter('Hello World!')); }
@issue https://github.com/zephir-lang/zephir/issues/1534
testShouldReturnWithParameterStaticVersion
php
zephir-lang/zephir
tests/Extension/ReturnsTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/ReturnsTest.php
MIT
public function testShouldReturnWithoutParameter(): void { $tester = new Returns(); $this->assertSame('Return back', $tester->returnWithoutParameter()); }
@issue https://github.com/zephir-lang/zephir/issues/1534
testShouldReturnWithoutParameter
php
zephir-lang/zephir
tests/Extension/ReturnsTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/ReturnsTest.php
MIT
public function testShouldReturnWithoutParameterStaticVersion(): void { $this->assertSame('Return back', Returns::returnWithoutParameter()); }
@issue https://github.com/zephir-lang/zephir/issues/1534
testShouldReturnWithoutParameterStaticVersion
php
zephir-lang/zephir
tests/Extension/ReturnsTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/ReturnsTest.php
MIT
public function testConstruct(): void { $test = new ScallLateConstruct(); $this->assertSame('hello public', $test->varValue()); }
@issue https://github.com/zephir-lang/zephir/issues/2111
testConstruct
php
zephir-lang/zephir
tests/Extension/ScallLateConstructTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/ScallLateConstructTest.php
MIT
public function testShouldReturnInterpolatedMethodFromZephir(): void { $test = new Scall(); $this->assertSame('hello Scall', $test->interpolatedStaticReturn()); }
@issue https://github.com/zephir-lang/zephir/issues/1622
testShouldReturnInterpolatedMethodFromZephir
php
zephir-lang/zephir
tests/Extension/ScallTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/ScallTest.php
MIT
public function testShouldEchoInterpolatedMethodFromZephir(): void { $test = new Scall(); ob_start(); $test->interpolatedStaticEcho(); $content = ob_get_clean(); $this->assertSame('hello Scall', $content); }
@issue https://github.com/zephir-lang/zephir/issues/1622
testShouldEchoInterpolatedMethodFromZephir
php
zephir-lang/zephir
tests/Extension/ScallTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/ScallTest.php
MIT
public function testIssue1212(): void { $this->assertInstanceOf(\SplFileObject::class, Spl::issue1212(__DIR__.'/../fixtures/class-empty.php')); }
@issue https://github.com/zephir-lang/zephir/issues/1212
testIssue1212
php
zephir-lang/zephir
tests/Extension/SplTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/SplTest.php
MIT
public function testShouldMutateIntVarInsideCycle(): void { $this->assertEquals( 42, SPropertyAccess::mutateIntVarInsideCycle() ); }
@issue https://github.com/zephir-lang/zephir/issues/1494
testShouldMutateIntVarInsideCycle
php
zephir-lang/zephir
tests/Extension/SPropertyAccessTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/SPropertyAccessTest.php
MIT
public function testShouldMutateDoubleVarInsideCycle(): void { $this->assertEquals( 3.14, SPropertyAccess::mutateDoubleVarInsideCycle() ); }
@issue https://github.com/zephir-lang/zephir/issues/1494
testShouldMutateDoubleVarInsideCycle
php
zephir-lang/zephir
tests/Extension/SPropertyAccessTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/SPropertyAccessTest.php
MIT
public function testHashEquals($knownString, $userString, $expected): void { $salt = '$2a$07$usesomesillystringforsalt$'; $knownString = crypt($knownString, $salt); $userString = crypt($userString, $salt); $this->assertSame($expected, $this->test->testHashEquals($knownString, $userString)); }
@dataProvider providerHashEquals @param mixed $knownString @param mixed $userString @param mixed $expected
testHashEquals
php
zephir-lang/zephir
tests/Extension/StringTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/StringTest.php
MIT
public function testHashEqualsNonString($knownString, $userString): void { $this->assertFalse($this->test->testHashEquals($knownString, $userString)); }
@dataProvider providerHashEqualsNonString @param mixed $knownString @param mixed $userString
testHashEqualsNonString
php
zephir-lang/zephir
tests/Extension/StringTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/StringTest.php
MIT
public function testSubstr(string $input, int $start, int $end, string $expected): void { $this->assertSame($this->test->testSubstr($input, $start, $end), $expected); $this->assertSame($this->test->testSubstr2($input, -1), 'f'); $this->assertSame($this->test->testSubstr2($input, -2), 'ef'); $this->assertSame($this->test->testSubstr2($input, 2), 'cdef'); $this->assertSame($this->test->testSubstr3($input), 'f'); $this->assertSame($this->test->testSubstr4($input), 'abcde'); }
@dataProvider providerSubstring @param string $input @param int $start @param int $end @param string $expected
testSubstr
php
zephir-lang/zephir
tests/Extension/StringTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/StringTest.php
MIT
public function testAddslashes(string $sample, string $expected): void { $this->assertSame($this->test->testAddslashes($sample), addslashes($expected)); }
@dataProvider providerAddStripSlashes @param string $sample @param string $expected
testAddslashes
php
zephir-lang/zephir
tests/Extension/StringTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/StringTest.php
MIT
public function testStripslashes(string $sample, string $expected): void { $this->assertSame($this->test->testStripslashes(addslashes($sample)), $expected); }
@dataProvider providerAddStripSlashes @param string $sample @param string $expected
testStripslashes
php
zephir-lang/zephir
tests/Extension/StringTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/StringTest.php
MIT
public function testNullableStringReturnType(): void { $this->assertNull($this->test->nullableStringReturnType()); $this->assertNull($this->test->nullableStringReturnType(null)); $this->assertSame('string', $this->test->nullableStringReturnType('string')); }
@issue https://github.com/zephir-lang/zephir/issues/1932
testNullableStringReturnType
php
zephir-lang/zephir
tests/Extension/StringTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/StringTest.php
MIT
public function testIssue2299NullableStringCondition(): void { $this->assertSame(null, $this->test->issue2299NullableStringCondition()); $this->assertSame('not-null', $this->test->issue2299NullableStringCondition('not-null')); $this->assertSame('test', $this->test->issue2299NullableStringCondition('test')); }
@issue https://github.com/zephir-lang/zephir/issues/2299
testIssue2299NullableStringCondition
php
zephir-lang/zephir
tests/Extension/StringTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/StringTest.php
MIT
public function testShouldNotTriggerAnyErrorIfPostIsUndefined(): void { $tester = new Post(); unset($_POST); $this->assertFalse(isset($_POST)); $this->assertFalse($tester->hasValue('issue-1623')); }
@issue https://github.com/zephir-lang/zephir/issues/1623
testShouldNotTriggerAnyErrorIfPostIsUndefined
php
zephir-lang/zephir
tests/Extension/Globals/PostTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Globals/PostTest.php
MIT
public function testShouldReturnFalseIfVariableIsUndefined(): void { $tester = new Post(); $_POST = []; $this->assertTrue(isset($_POST)); $this->assertFalse($tester->hasValue('issue-1623')); }
@issue https://github.com/zephir-lang/zephir/issues/1623
testShouldReturnFalseIfVariableIsUndefined
php
zephir-lang/zephir
tests/Extension/Globals/PostTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Globals/PostTest.php
MIT
public function testShouldReturnTrueIfVariableIsDefined(): void { $tester = new Post(); $_POST = ['issue-1623' => true]; $this->assertTrue(isset($_POST)); $this->assertTrue($tester->hasValue('issue-1623')); }
@issue https://github.com/zephir-lang/zephir/issues/1623
testShouldReturnTrueIfVariableIsDefined
php
zephir-lang/zephir
tests/Extension/Globals/PostTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Globals/PostTest.php
MIT
public function testShouldNotTriggerAnyErrorIfPostIsUndefined(): void { $tester = new ServerRequestFactory(); $_SERVER = null; $_GET = null; $_POST = null; $tester->load($_SERVER, $_GET, $_POST); $tester->load($_SERVER, $_GET, $_POST); $tester->load($_SERVER, $_GET, $_POST); $this->assertEquals( [ 'server' => [], 'files' => [], 'cookies' => [], 'get' => [], 'post' => [], ], $tester->load() ); }
@issue https://github.com/zephir-lang/zephir/issues/1934
testShouldNotTriggerAnyErrorIfPostIsUndefined
php
zephir-lang/zephir
tests/Extension/Globals/ServerRequestFactoryTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Globals/ServerRequestFactoryTest.php
MIT
public function testShouldPrintPhpSelf(): void { $test = new Server(); ob_start(); $test->f1(); $actual = ob_get_contents(); ob_end_clean(); $this->assertSame(str_repeat($_SERVER['PHP_SELF'], 3), $actual); }
@see https://github.com/zephir-lang/zephir/issues/1961
testShouldPrintPhpSelf
php
zephir-lang/zephir
tests/Extension/Globals/ServerTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Globals/ServerTest.php
MIT
public function testShouldPrintUserAgent(): void { $test = new Server(); $_SERVER['HTTP_USER_AGENT'] = 'Test'; $this->assertSame('Test', $test->check()); }
@see https://github.com/zephir-lang/zephir/issues/1961
testShouldPrintUserAgent
php
zephir-lang/zephir
tests/Extension/Globals/ServerTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Globals/ServerTest.php
MIT
protected function setUp(): void { parent::setUp(); if (!isset($_SESSION)) { $_SESSION = []; } }
This method is called before a test is executed.
setUp
php
zephir-lang/zephir
tests/Extension/Globals/SessionTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Globals/SessionTest.php
MIT
public function testShouldExtendMiddlewareInterface(): void { if (!\extension_loaded('psr')) { $this->markTestSkipped('The psr extension is not loaded'); } $this->assertTrue( is_subclass_of(MessageInterfaceEx::class, 'Psr\Http\Message\MessageInterface') ); }
@issue https://github.com/zephir-lang/zephir/issues/1686
testShouldExtendMiddlewareInterface
php
zephir-lang/zephir
tests/Extension/Oo/ExtendClassTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/ExtendClassTest.php
MIT
public function testShouldCorrectWorkWithLateStaticBinding(): void { $this->assertSame(ConcreteStatic::class, ConcreteStatic::getCalledClass()); }
@issue https://github.com/zephir-lang/zephir/issues/1392
testShouldCorrectWorkWithLateStaticBinding
php
zephir-lang/zephir
tests/Extension/Oo/ExtendClassTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/ExtendClassTest.php
MIT
public function testShouldCallParentMethodFromStaticByUsingSelf(): void { $this->assertSame('ConcreteStatic:parentFunction', ConcreteStatic::parentFunction()); if (version_compare(PHP_VERSION, '8.2.0', '<')) { $this->assertSame('ConcreteStatic:parentFunction', ConcreteStatic::childFunction()); } }
@issue https://github.com/zephir-lang/zephir/issues/1372
testShouldCallParentMethodFromStaticByUsingSelf
php
zephir-lang/zephir
tests/Extension/Oo/ExtendClassTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/ExtendClassTest.php
MIT
public function testWrongNumberParamsIssue938(): void { if (version_compare(PHP_VERSION, '8.0.0', '>=')) { $this->expectException(\ArgumentCountError::class); } else { $this->expectException(\BadMethodCallException::class); } $this->test->setAge(17, 'invalid'); }
@issue https://github.com/zephir-lang/zephir/issues/938
testWrongNumberParamsIssue938
php
zephir-lang/zephir
tests/Extension/Oo/OoParamsTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/OoParamsTest.php
MIT
public function testShouldNotSetPrivatePropertyObjPhp(): void { $this->expectException(\Error::class); $this->expectExceptionMessage( 'Cannot access private property TestScopePhp::$privateProperty' ); $tester = new PrivateScopeTester(); $tester->setPropertyObj(new \TestScopePhp(), 'privateProperty', 'test'); }
@see https://github.com/zephir-lang/zephir/issues/2057
testShouldNotSetPrivatePropertyObjPhp
php
zephir-lang/zephir
tests/Extension/Oo/Scopes/PrivateScopeTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/Scopes/PrivateScopeTest.php
MIT
public function testShouldNotSetPrivatePropertyNewPhp(): void { $this->expectException(\Error::class); $this->expectExceptionMessage( 'Cannot access private property TestScopePhp::$privateProperty' ); $tester = new PrivateScopeTester(); $tester->setPropertyNew(\TestScopePhp::class, 'privateProperty', 'test'); }
@see https://github.com/zephir-lang/zephir/issues/2057
testShouldNotSetPrivatePropertyNewPhp
php
zephir-lang/zephir
tests/Extension/Oo/Scopes/PrivateScopeTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/Scopes/PrivateScopeTest.php
MIT
public function testShouldNotSetPrivatePropertyObjInternal(): void { $this->expectException(\Error::class); $this->expectExceptionMessage( 'Cannot access private property TestScopeExtending::$privateProperty' ); $tester = new PrivateScopeTester(); $tester->setPropertyObj(new \TestScopeExtending(), 'privateProperty', 'test'); }
@see https://github.com/zephir-lang/zephir/issues/2057
testShouldNotSetPrivatePropertyObjInternal
php
zephir-lang/zephir
tests/Extension/Oo/Scopes/PrivateScopeTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/Scopes/PrivateScopeTest.php
MIT
public function testShouldNotSetPrivatePropertyNewInternal(): void { $this->expectException(\Error::class); $this->expectExceptionMessage( 'Cannot access private property TestScopeExtending::$privateProperty' ); $tester = new PrivateScopeTester(); $tester->setPropertyNew(\TestScopeExtending::class, 'privateProperty', 'test'); }
@see https://github.com/zephir-lang/zephir/issues/2057
testShouldNotSetPrivatePropertyNewInternal
php
zephir-lang/zephir
tests/Extension/Oo/Scopes/PrivateScopeTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/Scopes/PrivateScopeTest.php
MIT
public function testShouldSetPrivatePropertyObjPhp(): void { $object = new \TestScopePhpMagic(); $tester = new PrivateScopeTester(); $actual = $tester->setPropertyObj($object, 'privateProperty', 'test'); $this->assertEquals('test', $actual); $this->assertEquals(1, $object->setCount); }
@see https://github.com/zephir-lang/zephir/issues/2057
testShouldSetPrivatePropertyObjPhp
php
zephir-lang/zephir
tests/Extension/Oo/Scopes/PrivateScopeTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/Scopes/PrivateScopeTest.php
MIT
public function testShouldSetPrivatePropertyNewPhp(): void { $tester = new PrivateScopeTester(); $obj = $tester->setPropertyNew(\TestScopePhpMagic::class, 'privateProperty', 'test'); $this->assertEquals('test', $obj->privateProperty); $this->assertEquals(1, $obj->setCount); }
@see https://github.com/zephir-lang/zephir/issues/2057
testShouldSetPrivatePropertyNewPhp
php
zephir-lang/zephir
tests/Extension/Oo/Scopes/PrivateScopeTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/Scopes/PrivateScopeTest.php
MIT
public function testShouldSetPrivatePropertyObjInternal(): void { $tester = new PrivateScopeTester(); $object = new \TestScopeExtendingMagic(); $actual = $tester->setPropertyObj($object, 'privateProperty', 'test'); $this->assertEquals('test', $actual); $this->assertEquals(1, $object->setCount); }
@see https://github.com/zephir-lang/zephir/issues/2057
testShouldSetPrivatePropertyObjInternal
php
zephir-lang/zephir
tests/Extension/Oo/Scopes/PrivateScopeTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/Scopes/PrivateScopeTest.php
MIT
public function testShouldSetPrivatePropertyNewInternal(): void { $tester = new PrivateScopeTester(); $obj = $tester->setPropertyNew(\TestScopeExtendingMagic::class, 'privateProperty', 'test'); $this->assertEquals('test', $obj->privateProperty); $this->assertEquals(1, $obj->setCount); }
@see https://github.com/zephir-lang/zephir/issues/2057
testShouldSetPrivatePropertyNewInternal
php
zephir-lang/zephir
tests/Extension/Oo/Scopes/PrivateScopeTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/Scopes/PrivateScopeTest.php
MIT
public function testShouldNotSetPrivatePropertyViaThis(): void { $this->expectException(\Error::class); $this->expectExceptionMessage( 'Cannot access private property TestScopeExtending::$privateProperty' ); $obj = new \TestScopeExtending(); $obj->setProperty('privateProperty', 'test'); }
@see https://github.com/zephir-lang/zephir/issues/2057
testShouldNotSetPrivatePropertyViaThis
php
zephir-lang/zephir
tests/Extension/Oo/Scopes/PrivateScopeTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/Scopes/PrivateScopeTest.php
MIT
public function testShouldSetPrivatePropertyViaThis(): void { $obj = new \TestScopeExtending(); $obj->setProperty('privateProperty2', 'test'); $this->assertEquals('test', $obj->getPrivateProperty2()); }
@see https://github.com/zephir-lang/zephir/issues/2057
testShouldSetPrivatePropertyViaThis
php
zephir-lang/zephir
tests/Extension/Oo/Scopes/PrivateScopeTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/Scopes/PrivateScopeTest.php
MIT
public function testShouldNotSetPrivatePropertyExtendedMagicObjInternal(): void { $this->expectException(\Error::class); $this->expectExceptionMessage( 'Cannot access private property TestScopeExtendingMagic::$privateProperty2' ); $object = new \TestScopeExtendingMagic(); $tester = new PrivateScopeTester(); $this->assertEquals('private', $object->getPrivateProperty2()); $tester->setPropertyObj($object, 'privateProperty2', 'CHANGED'); }
@see https://github.com/zephir-lang/zephir/issues/2057
testShouldNotSetPrivatePropertyExtendedMagicObjInternal
php
zephir-lang/zephir
tests/Extension/Oo/Scopes/PrivateScopeTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/Scopes/PrivateScopeTest.php
MIT
public function testShouldNotSetPrivatePropertyExtendedMagicNewInternal(): void { $this->expectException(\Error::class); $this->expectExceptionMessage( 'Cannot access private property TestScopeExtendingMagic::$privateProperty2' ); $tester = new PrivateScopeTester(); $tester->setPropertyNew( \TestScopeExtendingMagic::class, 'privateProperty2', 'CHANGED' ); }
@see https://github.com/zephir-lang/zephir/issues/2057
testShouldNotSetPrivatePropertyExtendedMagicNewInternal
php
zephir-lang/zephir
tests/Extension/Oo/Scopes/PrivateScopeTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/Scopes/PrivateScopeTest.php
MIT
public function testShouldNotSetPrivatePropertyExtendedMagicObjPhp(): void { if (\PHP_VERSION_ID < 70400) { $this->expectException(Notice::class); $this->expectExceptionMessage( 'Undefined property: TestScopePhpMagicExtending::$privateProperty2' ); } else { $this->expectException(\Error::class); $this->expectExceptionMessage( 'Cannot access private property TestScopePhpMagicExtending::$privateProperty2' ); } $obj = new \TestScopePhpMagicExtending(); $tester = new PrivateScopeTester(); $tester->setPropertyObj($obj, 'privateProperty2', 'test'); }
@see https://github.com/zephir-lang/zephir/issues/2057
testShouldNotSetPrivatePropertyExtendedMagicObjPhp
php
zephir-lang/zephir
tests/Extension/Oo/Scopes/PrivateScopeTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/Scopes/PrivateScopeTest.php
MIT
public function testShouldNotSetPrivatePropertyExtendedMagicNewPhp(): void { $this->expectException(\Error::class); $this->expectExceptionMessage( 'Cannot access private property TestScopePhpMagicExtending::$privateProperty2' ); $tester = new PrivateScopeTester(); $tester->setPropertyNew( \TestScopePhpMagicExtending::class, 'privateProperty2', 'CHANGED' ); }
@see https://github.com/zephir-lang/zephir/issues/2057
testShouldNotSetPrivatePropertyExtendedMagicNewPhp
php
zephir-lang/zephir
tests/Extension/Oo/Scopes/PrivateScopeTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/Scopes/PrivateScopeTest.php
MIT
public function testShouldNotGetObjectVarsPrivatePropertyObjPhp(): void { $tester = new PrivateScopeTester(); $object = new \TestScopePhp(); $objectVars = $tester->getObjVars($object); $this->assertArrayNotHasKey('privateProperty', $objectVars); }
@see https://github.com/zephir-lang/zephir/issues/2057
testShouldNotGetObjectVarsPrivatePropertyObjPhp
php
zephir-lang/zephir
tests/Extension/Oo/Scopes/PrivateScopeTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/Scopes/PrivateScopeTest.php
MIT
public function testShouldNotGetObjectVarsPrivatePropertyNewPhp(): void { $tester = new PrivateScopeTester(); $objectVars = $tester->getNewVars(\TestScopePhp::class); $this->assertArrayNotHasKey('privateProperty', $objectVars); }
@see https://github.com/zephir-lang/zephir/issues/2057
testShouldNotGetObjectVarsPrivatePropertyNewPhp
php
zephir-lang/zephir
tests/Extension/Oo/Scopes/PrivateScopeTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/Scopes/PrivateScopeTest.php
MIT
public function testShouldNotGetObjectVarsPrivatePropertyObjInternal(): void { $tester = new PrivateScopeTester(); $object = new \TestScopeExtending(); $objectVars = $tester->getObjVars($object); $this->assertArrayNotHasKey('privateProperty', $objectVars); }
@see https://github.com/zephir-lang/zephir/issues/2057
testShouldNotGetObjectVarsPrivatePropertyObjInternal
php
zephir-lang/zephir
tests/Extension/Oo/Scopes/PrivateScopeTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/Scopes/PrivateScopeTest.php
MIT
public function testShouldNotGetObjectVarsPrivatePropertyNewInternal(): void { $tester = new PrivateScopeTester(); $objectVars = $tester->getNewVars(\TestScopeExtending::class); $this->assertArrayNotHasKey('privateProperty', $objectVars); }
@see https://github.com/zephir-lang/zephir/issues/2057
testShouldNotGetObjectVarsPrivatePropertyNewInternal
php
zephir-lang/zephir
tests/Extension/Oo/Scopes/PrivateScopeTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/Scopes/PrivateScopeTest.php
MIT
public function testShouldGetAndSetPrivatePropertyUsingParentGetterAndSetter(): void { $tester = new \UserExample(); $tester->setPrivateVariable('test'); $this->assertEquals('test', $tester->getPrivateVariable()); }
@see https://github.com/zephir-lang/zephir/issues/1851
testShouldGetAndSetPrivatePropertyUsingParentGetterAndSetter
php
zephir-lang/zephir
tests/Extension/Oo/Scopes/PrivateScopeTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Oo/Scopes/PrivateScopeTest.php
MIT
public function testOptimizer($version, $expected): void { $isPhpVersion = $this->isPhpVersion($version); $this->assertEquals($expected, $isPhpVersion); }
@dataProvider phpVersionProvider @param mixed $version @param mixed $expected @throws \Exception
testOptimizer
php
zephir-lang/zephir
tests/Extension/Optimizers/IsPhpVersionTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Optimizers/IsPhpVersionTest.php
MIT
public function testIsPhpVersionVersionUsing701XX($testName, $version): void { $actual = $this->test->$testName(); $expected = $this->isPhpVersion($version); $this->assertEquals($expected, $actual); }
@dataProvider releaseVersionProvider @param mixed $testName @param mixed $version @throws \Exception
testIsPhpVersionVersionUsing701XX
php
zephir-lang/zephir
tests/Extension/Optimizers/IsPhpVersionTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Optimizers/IsPhpVersionTest.php
MIT
public function testIsPhpVersionVersionUsing70X00($testName, $version): void { $actual = $this->test->$testName(); $expected = $this->isPhpVersion($version); $this->assertEquals($expected, $actual); }
@dataProvider minorVersionProvider @param mixed $testName @param mixed $version @throws \Exception
testIsPhpVersionVersionUsing70X00
php
zephir-lang/zephir
tests/Extension/Optimizers/IsPhpVersionTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Optimizers/IsPhpVersionTest.php
MIT
private function isPhpVersion(float | int | string $version): bool { preg_match('/^(?<major>\d+)(?:\.(?<minor>!?\d+))?(?:\.(?<patch>!?\d+))?(?:[^Ee0-9.]+.*)?$/', (string) $version, $matches); if (!\count($matches)) { throw new \Exception('Could not parse PHP version'); } $minorVersion = 0; $releaseVersion = 0; $phpMinorVersion = 0; $phpReleaseVersion = 0; $majorVersion = $matches['major'] * 10000; $phpMajorVersion = PHP_MAJOR_VERSION * 10000; if (isset($matches['minor'])) { $minorVersion = $matches['minor'] * 100; $phpMinorVersion = PHP_MINOR_VERSION * 100; } if (isset($matches['patch'])) { $releaseVersion = $matches['patch']; $phpReleaseVersion = PHP_RELEASE_VERSION; } $versionId = (int) ($majorVersion + $minorVersion + $releaseVersion); $phpVersionId = $phpMajorVersion + $phpMinorVersion + $phpReleaseVersion; return $phpVersionId === $versionId; }
Optimizer: isPhpVersion Compare user entered PHP version with Environment and return Boolean Check only MAJOR or MAJOR + MINOR or MAJOR + MINOR + RELEASE. @param float|int|string $version - PHP version in any format: 7, 7.1, "7.1.1" @return bool @throws \Exception
isPhpVersion
php
zephir-lang/zephir
tests/Extension/Optimizers/IsPhpVersionTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Optimizers/IsPhpVersionTest.php
MIT
public function testIssue1245ShouldReturnAllVisibilityProperties(): void { $test = new GetObjectVars(); $this->assertSame(['a' => 1, 'b' => 2, 'c' => 3], $test->issue1245()); }
@issue https://github.com/zephir-lang/zephir/issues/1245
testIssue1245ShouldReturnAllVisibilityProperties
php
zephir-lang/zephir
tests/Extension/Properties/GetObjectVarsTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Properties/GetObjectVarsTest.php
MIT
public function testShouldSetAndGetProtectedPropertyUsingExtendedClass(): void { $test = new \ExtendsProtectedProperties(); $this->assertEquals(['key' => 'value'], $test->getSomeArrayVar()); $test->setSomeArrayVar(['key' => 'value']); $this->assertEquals(['key' => 'value'], $test->getSomeArrayVar()); $test->setSomeArrayVar(['key2' => 'value2']); $this->assertEquals(['key2' => 'value2'], $test->getSomeArrayVar()); }
@issue https://github.com/zephir-lang/zephir/issues/2089
testShouldSetAndGetProtectedPropertyUsingExtendedClass
php
zephir-lang/zephir
tests/Extension/Properties/ProtectedPropertiesTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Properties/ProtectedPropertiesTest.php
MIT
public function test537Issue(): void { $test = new ExtendsPublicProperties(); $this->assertSame($test->getSomeGetterSetterArray(), ['holy']); }
@issue https://github.com/zephir-lang/zephir/issues/537
test537Issue
php
zephir-lang/zephir
tests/Extension/Properties/PublicPropertiesTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Properties/PublicPropertiesTest.php
MIT
public function testShouldGetInstanceByUsingSingleton(): void { $test = new App(); $this->assertInstanceOf(StaticPrivateProperties::class, $test->getInstance()); $this->assertInstanceOf(StaticPrivateProperties::class, StaticPrivateProperties::getInstance()); $this->assertSame($test->getInstance(), StaticPrivateProperties::getInstance()); }
@issue https://github.com/zephir-lang/zephir/issues/1530
testShouldGetInstanceByUsingSingleton
php
zephir-lang/zephir
tests/Extension/Properties/StaticPrivatePropertiesTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/Properties/StaticPrivatePropertiesTest.php
MIT
public function testShouldCreateCompatibleChildClassUsingTypeHintedParams(): void { $childClass = new \TestConcreteClass(); $this->assertEquals( [[1667], '/', true, null], $childClass->testFunc([1667], '/', true, null) ); $this->assertEquals( [['issue'], '\\', true, 1667], $childClass->testFunc(['issue'], '\\', true, 1667) ); }
@issue https://github.com/zephir-lang/zephir/issues/1667
testShouldCreateCompatibleChildClassUsingTypeHintedParams
php
zephir-lang/zephir
tests/Extension/TypeHinting/AbstractTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/TypeHinting/AbstractTest.php
MIT
public function testShouldCreateCompatibleChildClassWithMultipleReturnTypesHint(): void { $childClass = new \TestConcreteClass(); $this->assertEquals('TestConcreteClass::returnOneOfScalar', $childClass->returnOneOfScalar()); }
@issue https://github.com/zephir-lang/zephir/issues/1667
testShouldCreateCompatibleChildClassWithMultipleReturnTypesHint
php
zephir-lang/zephir
tests/Extension/TypeHinting/AbstractTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/TypeHinting/AbstractTest.php
MIT
public function testShouldCreateCompatibleChildClassWithScalarType(): void { $childClass = new \TestConcreteClass(); $this->assertEquals(1, $childClass->returnInt()); $this->assertEquals(1, $childClass->returnUint()); $this->assertEquals(1, $childClass->returnLong()); $this->assertEquals(1.0, $childClass->returnFloat()); $this->assertEquals(1.0, $childClass->returnDouble()); $this->assertEquals('TestConcreteClass::returnString', $childClass->returnString()); $this->assertTrue($childClass->returnBoolean()); $this->assertEquals(1, $childClass->returnChar()); }
@issue https://github.com/zephir-lang/zephir/issues/1667
testShouldCreateCompatibleChildClassWithScalarType
php
zephir-lang/zephir
tests/Extension/TypeHinting/AbstractTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Extension/TypeHinting/AbstractTest.php
MIT
public function testShouldProperAddStatements(array $useStatements, array $expected): void { $this->testAliasMgr->add([ 'aliases' => [$useStatements], ]); $className = $useStatements['name']; $parts = explode('\\', $className); $alias = $useStatements['alias'] ?? $parts[\count($parts) - 1]; $this->assertTrue($this->testAliasMgr->isAlias($alias)); $this->assertSame($expected, $this->testAliasMgr->getAliases()); $this->assertSame($className, $this->testAliasMgr->getAlias($alias)); }
@dataProvider aliasProvider @param array $useStatements @param array $expected
testShouldProperAddStatements
php
zephir-lang/zephir
tests/Zephir/AliasManagerTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/AliasManagerTest.php
MIT
public function testShouldCheckAliasedStatement(array $useStatements, bool $expected): void { $this->testAliasMgr->add([ 'aliases' => [$useStatements], ]); $className = $useStatements['name']; $parts = explode('\\', $className); $alias = $useStatements['alias'] ?? $parts[\count($parts) - 1]; $this->assertSame($expected, $this->testAliasMgr->isUseStatementAliased($alias)); $this->assertSame($expected, $this->testAliasMgr->isAliasPresentFor($className)); }
@dataProvider statementProvider @param array $useStatements @param bool $expected
testShouldCheckAliasedStatement
php
zephir-lang/zephir
tests/Zephir/AliasManagerTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/AliasManagerTest.php
MIT
public function testShouldGetAliasForClassName(array $useStatements, string $expected): void { $this->testAliasMgr->add([ 'aliases' => [$useStatements], ]); $className = $useStatements['name']; $this->assertSame($expected, $this->testAliasMgr->getAliasForClassName($className)); }
@dataProvider classNameDataProvider @param array $useStatements @param string $expected
testShouldGetAliasForClassName
php
zephir-lang/zephir
tests/Zephir/AliasManagerTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/AliasManagerTest.php
MIT
private function cleanTmpConfigFile(): void { /* clean config.json into tmp dir */ $tmpConfigFile = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'config.json'; if (file_exists($tmpConfigFile)) { unlink($tmpConfigFile); } }
Clean config.json file into tmp dir.
cleanTmpConfigFile
php
zephir-lang/zephir
tests/Zephir/ConfigTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/ConfigTest.php
MIT
private function stubsBanner(): string { return <<<DOC /** * This file is part of the Zephir. * * (c) Phalcon Team <[email protected]> * * For the full copyright and license information, please view * the LICENSE file that was distributed with this source code. */ DOC; }
Returns Stubs banner for test suite. @return string
stubsBanner
php
zephir-lang/zephir
tests/Zephir/ConfigTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/ConfigTest.php
MIT
public function testConstructWithBadConfigFile(): void { $this->expectException(\Zephir\Exception::class); $this->expectExceptionMessage('The config.json file is invalid: Syntax error, malformed JSON'); chdir(\constant('ZEPHIRPATH').'/tests/fixtures/badconfig'); new Config(); }
Test when we have a bad config.json file.
testConstructWithBadConfigFile
php
zephir-lang/zephir
tests/Zephir/ConfigTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/ConfigTest.php
MIT
public function setConfigProvider(): array { return [ 'set with namespace' => [ ['unused-variable', false, 'warnings'], false, ], 'set without namespace' => [ ['config', true, null], true, ], 'get with namespace' => [ ['unused-variable', true, 'warnings'], true, ], 'get without namespace' => [ ['verbose', false, null], false, ], 'directive don`t have duplicates with namespace' => [ ['ext.some_key', 'some_value', 'test'], 'some_value', ], 'directive don`t have duplicates without namespace' => [ ['test.my_setting_1', 'test', null], 'test', ], ]; }
Test data provider. [ 'test name' => [ [$key, $value, $namespace], $expected, ], ... ] @return array
setConfigProvider
php
zephir-lang/zephir
tests/Zephir/ConfigTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/ConfigTest.php
MIT
public function testShouldSetConfigParams(array $test, $expected): void { [$key, $value, $namespace] = $test; $this->config->set($key, $value, $namespace); $actual = $this->config->get($key, $namespace); $this->assertSame($expected, $actual); }
@dataProvider setConfigProvider @param array $test @param mixed $expected
testShouldSetConfigParams
php
zephir-lang/zephir
tests/Zephir/ConfigTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/ConfigTest.php
MIT
public function testShouldGetDefaultConfigParams($namespace, string $key, $expected): void { if (Os::isWindows()) { $this->markTestSkipped('Warning: Strings contain different line endings!'); } $actual = $this->config->get($key, $namespace); $this->assertSame($expected, $actual); }
@dataProvider defaultConfigProvider @param mixed $namespace @param string $key @param mixed $expected
testShouldGetDefaultConfigParams
php
zephir-lang/zephir
tests/Zephir/ConfigTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/ConfigTest.php
MIT
public function testShouldGetWithOffsetConfigParams(array $key, array $expected): void { $actual = $this->config->offsetGet($key); $this->assertSame($expected, $actual); }
@dataProvider offsetConfigProvider @param array $key @param array $expected
testShouldGetWithOffsetConfigParams
php
zephir-lang/zephir
tests/Zephir/ConfigTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/ConfigTest.php
MIT
private function buildReturnTypes(array $returnTypesList): array { return [ 'type' => 'return-type', 'list' => $returnTypesList, 'void' => 0, 'file' => 'stubs.zep', 'line' => 1, 'char' => 42, ]; }
Helper to build proper structure with method return types. @param array $returnTypesList - collactions with all return types @return array
buildReturnTypes
php
zephir-lang/zephir
tests/Zephir/TypesTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/TypesTest.php
MIT
private function baseReturnTypeDefinition(array $types, int $mandatory = 0): array { return array_map( function ($type) use ($mandatory) { return [ 'type' => 'return-type-parameter', 'data-type' => $type, 'mandatory' => $mandatory, 'file' => 'stubs.zep', 'line' => 1, 'char' => 42, ]; }, $types ); }
Builds base object definition for return type. @param array $types - list of method return types @param int $mandatory - is mandatory flag @return array
baseReturnTypeDefinition
php
zephir-lang/zephir
tests/Zephir/TypesTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/TypesTest.php
MIT
private function variableReturnTypeDefinition(array $types, int $collection = 0): array { return array_map( function ($type) use ($collection) { return [ 'type' => 'return-type-parameter', 'cast' => [ 'type' => 'variable', 'value' => $type, 'file' => 'stubs.zep', 'line' => 8, 'char' => 5, ], 'collection' => $collection, 'file' => 'stubs.zep', 'line' => 8, 'char' => 5, ]; }, $types ); }
Builds variable/collection object definition for return type. @param array $types - list of method return types @param int $collection - is collection flag @return array
variableReturnTypeDefinition
php
zephir-lang/zephir
tests/Zephir/TypesTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/TypesTest.php
MIT
private function buildMethod(array $testData, int $definition = 0): Method { return new Method( new Definition('Zephir', 'testMethod'), ['public'], 'exampleMethodName', null, null, null, $this->buildReturnTypes($testData, $definition) ); }
Helper to build test Method with injected test data. @param array $testData - dataProvider data set @param int $definition - (optional) one of mandatory/collection flag
buildMethod
php
zephir-lang/zephir
tests/Zephir/TypesTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/TypesTest.php
MIT
public function testShouldResolveCompatibleTypeForBaseTypes(array $returnTypes, string $expected): void { $testMethod = $this->buildMethod( $this->baseReturnTypeDefinition($returnTypes) ); $testTypes = new Types(); $actual = $testTypes->getReturnTypeAnnotation($testMethod); $this->assertSame($expected, $actual); }
@dataProvider typesProvider @param array $returnTypes @param string $expected
testShouldResolveCompatibleTypeForBaseTypes
php
zephir-lang/zephir
tests/Zephir/TypesTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/TypesTest.php
MIT
public function testShouldResolveCompatibleTypeForObjects(array $returnTypes, string $expected): void { $withAliases = []; foreach ($returnTypes as $alias) { $withAliases[$alias] = 'Stubs\\'.$alias; } $testMethod = $this->buildMethod( $this->baseReturnTypeDefinition($returnTypes) ); $testTypes = new Types(); $actual = $testTypes->getReturnTypeAnnotation( $testMethod, $withAliases ); $this->assertSame($expected, $actual); }
@dataProvider objectsProvider @param array $returnTypes @param string $expected
testShouldResolveCompatibleTypeForObjects
php
zephir-lang/zephir
tests/Zephir/TypesTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/TypesTest.php
MIT
public function testShouldResolveCompatibleTypeForCollections(array $returnTypes, string $expected): void { $typesList = []; $collections = []; foreach ($returnTypes as $type) { if (str_contains($type, '[]')) { $typesList[] = $this->variableReturnTypeDefinition([$type], 1)[0]; $collectionType = trim($type, '<>'); $collections[$collectionType] = $collectionType; } else { $typesList[] = $this->baseReturnTypeDefinition([$type])[0]; } } $testMethod = $this->buildMethod($typesList); $testTypes = new Types(); $actual = $testTypes->getReturnTypeAnnotation( $testMethod, array_merge($testMethod->getReturnTypes(), $collections) ); $this->assertSame($expected, $actual); }
@dataProvider collectionsProvider @param array $returnTypes @param string $expected
testShouldResolveCompatibleTypeForCollections
php
zephir-lang/zephir
tests/Zephir/TypesTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/TypesTest.php
MIT
public function testShouldEscapeStringWithRegexp(string $testString, string $expectedString): void { $backend = new Backend(new Config(), '', ''); $variable = new Variable('variable', 'name'); $context = new CompilationContext(); $actual = $backend->assignString($variable, $testString, $context, false); $expected = 'ZVAL_STRING(&name, "'.$expectedString.'");'; $this->assertSame($expected, $actual); }
@dataProvider stringDataProvider @param string $testString @param string $expectedString
testShouldEscapeStringWithRegexp
php
zephir-lang/zephir
tests/Zephir/Backends/ZendEngine3/BackendTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/Backends/ZendEngine3/BackendTest.php
MIT
public function testShouldDetectsIfVariableIsUsedInGivenExpressionContext(bool $expected, string $variable, array $expression): void { $detector = new ReadDetector(); $this->assertSame($expected, $detector->detect($variable, $expression)); }
@dataProvider variableProvider @param bool $expected @param string $variable @param array $expression
testShouldDetectsIfVariableIsUsedInGivenExpressionContext
php
zephir-lang/zephir
tests/Zephir/Detectors/ReadDetectorTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/Detectors/ReadDetectorTest.php
MIT
public function testShouldThrowExceptionIfNoParametersGiven(): void { $this->expectException(CompilerException::class); $this->expectExceptionMessage('preg_match() expects at least 2 parameters, 0 given'); $optimizer = new PregMatchOptimizer(); $optimizer->optimize( [], $this->callMock, $this->contextMock ); }
@issue https://github.com/zephir-lang/zephir/issues/1697
testShouldThrowExceptionIfNoParametersGiven
php
zephir-lang/zephir
tests/Zephir/Optimizers/FunctionCall/PregMatchOptimizerTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/Optimizers/FunctionCall/PregMatchOptimizerTest.php
MIT
public function testShouldThrowExceptionIfParametersLessThanRequired(): void { $this->expectException(CompilerException::class); $this->expectExceptionMessage('preg_match() expects at least 2 parameters, 0 given'); $optimizer = new PregMatchOptimizer(); $optimizer->optimize( ['parameters' => []], $this->callMock, $this->contextMock ); }
@issue https://github.com/zephir-lang/zephir/issues/1697
testShouldThrowExceptionIfParametersLessThanRequired
php
zephir-lang/zephir
tests/Zephir/Optimizers/FunctionCall/PregMatchOptimizerTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/Optimizers/FunctionCall/PregMatchOptimizerTest.php
MIT
public function testShouldThrowExceptionIfParametersMoreThanRequired(): void { $this->expectException(CompilerException::class); $this->expectExceptionMessage('preg_match() expects at most 5 parameters, 7 given'); $optimizer = new PregMatchOptimizer(); $optimizer->optimize( ['parameters' => [0, 1, 2, 3, 4, 5, 6]], $this->callMock, $this->contextMock ); }
@issue https://github.com/zephir-lang/zephir/issues/1697
testShouldThrowExceptionIfParametersMoreThanRequired
php
zephir-lang/zephir
tests/Zephir/Optimizers/FunctionCall/PregMatchOptimizerTest.php
https://github.com/zephir-lang/zephir/blob/master/tests/Zephir/Optimizers/FunctionCall/PregMatchOptimizerTest.php
MIT