forked from phalcon/phalcon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#ests] - annotations tests for phpunit
- Loading branch information
Showing
50 changed files
with
1,407 additions
and
868 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
tests/support/data/fixtures/Annotations/Adapter/StreamEmptyDataFixture.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <team@phalcon.io> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace MyLibrary\Tests\support\data\fixtures\Annotations\Adapter; | ||
|
||
use Phalcon\Annotations\Adapter\Stream; | ||
|
||
class StreamEmptyDataFixture extends Stream | ||
{ | ||
/** | ||
* @param string $filename | ||
* | ||
* @return bool | ||
* | ||
* @link https://php.net/manual/en/function.file-exists.php | ||
*/ | ||
protected function phpFileExists(string $filename) | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* @param string $filename | ||
* | ||
* @return string|false | ||
* | ||
* @link https://php.net/manual/en/function.file-get-contents.php | ||
*/ | ||
protected function phpFileGetContents(string $filename) | ||
{ | ||
return ''; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
tests/support/data/fixtures/Annotations/Adapter/StreamFileExistsFixture.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <team@phalcon.io> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Phalcon\Tests1\Fixtures\Annotations\Adapter; | ||
|
||
use Phalcon\Annotations\Adapter\Stream; | ||
|
||
class StreamFileExistsFixture extends Stream | ||
{ | ||
/** | ||
* @param string $filename | ||
* | ||
* @return bool | ||
* | ||
* @link https://php.net/manual/en/function.file-exists.php | ||
*/ | ||
protected function phpFileExists(string $filename) | ||
{ | ||
return false; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
tests/support/data/fixtures/Annotations/Adapter/StreamFixture.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <team@phalcon.io> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Phalcon\Tests1\Fixtures\Annotations\Adapter; | ||
|
||
use Phalcon\Annotations\Adapter\Stream; | ||
|
||
class StreamFixture extends Stream | ||
{ | ||
/** | ||
* @param string $filename | ||
* @param mixed $data | ||
* @param int $flags | ||
* @param resource $context | ||
* | ||
* @return int|false | ||
* | ||
* @link https://php.net/manual/en/function.file-put-contents.php | ||
*/ | ||
protected function phpFilePutContents( | ||
string $filename, | ||
$data, | ||
int $flags = 0, | ||
$context = null | ||
) { | ||
return false; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
tests/support/data/fixtures/Annotations/Adapter/StreamWrongDataFixture.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <team@phalcon.io> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace MyLibrary\Tests\support\data\fixtures\Annotations\Adapter; | ||
|
||
use Phalcon\Annotations\Adapter\Stream; | ||
|
||
class StreamWrongDataFixture extends Stream | ||
{ | ||
/** | ||
* @param string $filename | ||
* | ||
* @return bool | ||
* | ||
* @link https://php.net/manual/en/function.file-exists.php | ||
*/ | ||
protected function phpFileExists(string $filename) | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* @param string $filename | ||
* | ||
* @return string|false | ||
* | ||
* @link https://php.net/manual/en/function.file-get-contents.php | ||
*/ | ||
protected function phpFileGetContents(string $filename) | ||
{ | ||
return '{a:1'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <team@phalcon.io> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
/** | ||
* TestClass | ||
* | ||
* This is a test class, it's useful to make tests | ||
* | ||
* @Simple | ||
* @SingleParam("Param") | ||
* @MultipleParams("First", Second, 1, 1.1, -10, false, true, null) | ||
* @Params({"key1", "key2", "key3"}); | ||
* @HashParams({"key1": "value", "key2": "value", "key3": "value"}); | ||
* @NamedParams(first=some, second=other); | ||
* @AlternativeNamedParams(first: some, second: other); | ||
* @AlternativeHashParams({key1="value", "key2"=value, "key3"="value"}); | ||
* @RecursiveHash({key1="value", "key2"=value, "key3"=[1, 2, 3, 4]}); | ||
*/ | ||
class TestClass | ||
{ | ||
/** | ||
* @Simple | ||
*/ | ||
const TEST_CONST1 = 'test-const-with-annotation'; | ||
|
||
const TEST_CONST2 = 'test-const-without-annotation'; | ||
|
||
/** | ||
* This is a property string | ||
* | ||
* @var string | ||
* @Simple | ||
* @SingleParam("Param") | ||
* @MultipleParams("First", Second, 1, 1.1, -10, false, true, null) | ||
*/ | ||
public $testProp1; | ||
|
||
/** | ||
* | ||
*/ | ||
public $testProp2; | ||
|
||
/** | ||
* @Simple @SingleParam("Param") @MultipleParams("First", Second, 1, 1.1, | ||
* -10, false, true, null) | ||
*/ | ||
public $testProp3; | ||
|
||
/** | ||
* @Simple @SingleParam( | ||
* "Param") @MultipleParams( "First", | ||
* Second, 1, 1.1 | ||
* ,-10, | ||
* false, true, | ||
* null) | ||
*/ | ||
public $testProp4; | ||
|
||
public $testProp5; | ||
|
||
/** | ||
* This is a comment | ||
*/ | ||
public $testProp6; | ||
|
||
/** | ||
* This is a property string | ||
* | ||
* @return string | ||
* @Simple | ||
* @SingleParam("Param") | ||
* @MultipleParams("First", Second, 1, 1.1, -10, false, true, null) | ||
* @NamedMultipleParams(first: "First", second: Second) | ||
*/ | ||
public function testMethod1() | ||
{ | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function testMethod2() | ||
{ | ||
} | ||
|
||
/** | ||
* @Simple @SingleParam("Param") @MultipleParams("First", Second, 1, 1.1, | ||
* -10, false, true, null) | ||
*/ | ||
public function testMethod3() | ||
{ | ||
} | ||
|
||
/** | ||
* @Simple @SingleParam( | ||
* "Param") @MultipleParams( "First", | ||
* Second, 1, 1.1 | ||
* ,-10, | ||
* false, true, | ||
* null) | ||
*/ | ||
public function testMethod4() | ||
{ | ||
} | ||
|
||
/** @Simple a good comment between annotations @SingleParam( | ||
* "Param") this is extra content @MultipleParams( "First", | ||
* Second, 1, 1.1 ,-10, | ||
* false, true, | ||
* null) more content here | ||
*/ | ||
public function testMethod5() | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <team@phalcon.io> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace User; | ||
|
||
/** | ||
* User\TestClassNs | ||
* | ||
* This class has annotations but it's in a namespace | ||
* | ||
* @Simple | ||
* @SingleParam("Param") | ||
* @MultipleParams("First", Second, 1, 1.1, -10, false, true, null) | ||
* @Params({"key1", "key2", "key3"}); | ||
* @HashParams({"key1": "value", "key2": "value", "key3": "value"}); | ||
* @NamedParams(first=some, second=other); | ||
* @AlternativeNamedParams(first: some, second: other); | ||
* @AlternativeHashParams({key1="value", "key2"=value, "key3"="value"}); | ||
* @RecursiveHash({key1="value", "key2"=value, "key3"=[1, 2, 3, 4]}); | ||
*/ | ||
class TestClassNs | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <team@phalcon.io> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
/** | ||
* @Invalid( | ||
*/ | ||
class TestInvalid | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <team@phalcon.io> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Phalcon\Tests1\Fixtures\Traits; | ||
|
||
use Phalcon\Annotations\Adapter\Apcu; | ||
use Phalcon\Annotations\Adapter\Memory; | ||
use Phalcon\Annotations\Adapter\Stream; | ||
|
||
use function outputDir; | ||
use function outputDir2; | ||
|
||
trait AnnotationsTrait2 | ||
{ | ||
public static function providerExamples(): array | ||
{ | ||
return [ | ||
[ | ||
Apcu::class, | ||
[ | ||
'prefix' => 'nova_prefix', | ||
'lifetime' => 3600, | ||
], | ||
], | ||
[ | ||
Memory::class, | ||
[], | ||
], | ||
[ | ||
Stream::class, | ||
[ | ||
'annotationsDir' => outputDir2('annotations/'), | ||
], | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.