-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Valentin V / vvval
committed
Nov 11, 2019
1 parent
cb615cd
commit 9ec9141
Showing
10 changed files
with
180 additions
and
25 deletions.
There are no files selected for viewing
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
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
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
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
20 changes: 20 additions & 0 deletions
20
tests/Promise/ProxyPrinter/Fixtures/EntityWithProperties.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,20 @@ | ||
<?php | ||
|
||
/** | ||
* Spiral Framework. Cycle ProxyFactory | ||
* | ||
* @license MIT | ||
* @author Valentin V (Vvval) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cycle\ORM\Promise\Tests\ProxyPrinter\Fixtures; | ||
|
||
class EntityWithProperties | ||
{ | ||
public $publicProperty; | ||
public $publicPropertyWithDefaults = 'defaultPublicValue'; | ||
protected $protectedProperty; | ||
protected $protectedPropertyWithDefaults = 'defaultProtectedValue'; | ||
} |
21 changes: 21 additions & 0 deletions
21
tests/Promise/ProxyPrinter/Fixtures/EntityWithProperties74.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,21 @@ | ||
<?php | ||
|
||
/** | ||
* Spiral Framework. Cycle ProxyFactory | ||
* | ||
* @license MIT | ||
* @author Valentin V (Vvval) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cycle\ORM\Promise\Tests\ProxyPrinter\Fixtures; | ||
|
||
class EntityWithProperties74 | ||
{ | ||
public $publicProperty; | ||
public string $publicTypedProperty; | ||
public $publicPropertyWithDefaults = 'defaultPublicValue'; | ||
protected $protectedProperty; | ||
protected $protectedPropertyWithDefaults = 'defaultProtectedValue'; | ||
} |
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
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
<?php | ||
namespace Cycle\ORM\Promise\Tests\Promises; class FileTestThree {} | ||
// phpcs:ignoreFile | ||
namespace Cycle\ORM\Promise\Tests\Promises; class FileTestThree {} |
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,91 @@ | ||
<?php | ||
|
||
/** | ||
* Spiral Framework. Cycle ProxyFactory | ||
* | ||
* @license MIT | ||
* @author Valentin V (Vvval) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cycle\ORM\Promise\Tests74; | ||
|
||
use Cycle\ORM\Promise\Declaration\DeclarationInterface; | ||
use Cycle\ORM\Promise\Declaration\Declarations; | ||
use Cycle\ORM\Promise\Printer; | ||
use PhpParser\PrettyPrinter\Standard; | ||
use PhpParser\PrettyPrinterAbstract; | ||
use PHPUnit\Framework\TestCase; | ||
use Spiral\Core\Container; | ||
|
||
class ConstantsPHP74Test extends TestCase | ||
{ | ||
protected const NS = 'Cycle\ORM\Promise\Tests74\Promises'; | ||
|
||
/** @var \Spiral\Core\Container */ | ||
protected $container; | ||
|
||
/** | ||
* @throws \Cycle\ORM\Promise\Exception\ProxyFactoryException | ||
* @throws \ReflectionException | ||
* @throws \Throwable | ||
*/ | ||
public function testConstValues(): void | ||
{ | ||
$classname = Fixtures\EntityWithProperties74::class; | ||
$as = self::NS . __CLASS__ . __LINE__; | ||
$reflection = new \ReflectionClass($classname); | ||
|
||
$parent = Declarations::createParentFromReflection($reflection); | ||
$class = Declarations::createClassFromName($as, $parent); | ||
|
||
$output = $this->make($reflection, $class, $parent); | ||
$output = ltrim($output, '<?php'); | ||
|
||
$this->assertStringContainsString( | ||
"PUBLIC_PROPERTIES = ['publicProperty', 'publicTypedProperty', 'publicPropertyWithDefaults'];", | ||
$output | ||
); | ||
|
||
$this->assertStringContainsString( | ||
"UNSET_PROPERTIES = ['publicProperty', 'publicPropertyWithDefaults'];", | ||
$output | ||
); | ||
} | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->container = new Container(); | ||
} | ||
|
||
/** | ||
* @param \ReflectionClass $reflection | ||
* @param DeclarationInterface $class | ||
* @param DeclarationInterface $parent | ||
* @return string | ||
* @throws \Cycle\ORM\Promise\Exception\ProxyFactoryException | ||
* @throws \ReflectionException | ||
* @throws \Throwable | ||
*/ | ||
protected function make( | ||
\ReflectionClass $reflection, | ||
DeclarationInterface $class, | ||
DeclarationInterface $parent | ||
): string { | ||
return $this->proxyCreator()->make($reflection, $class, $parent); | ||
} | ||
|
||
/** | ||
* @return \Cycle\ORM\Promise\Printer | ||
* @throws \Throwable | ||
*/ | ||
private function proxyCreator(): Printer | ||
{ | ||
$this->container->bind(PrettyPrinterAbstract::class, Standard::class); | ||
|
||
return $this->container->get(Printer::class); | ||
} | ||
} |
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,21 @@ | ||
<?php | ||
|
||
/** | ||
* Spiral Framework. Cycle ProxyFactory | ||
* | ||
* @license MIT | ||
* @author Valentin V (Vvval) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cycle\ORM\Promise\Tests74\Fixtures; | ||
|
||
class EntityWithProperties74 | ||
{ | ||
public $publicProperty; | ||
public string $publicTypedProperty; | ||
public $publicPropertyWithDefaults = 'defaultPublicValue'; | ||
protected $protectedProperty; | ||
protected $protectedPropertyWithDefaults = 'defaultProtectedValue'; | ||
} |