Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
entity: fixed primary proxy for non-array single-column-PK & more con…
…version for primary proxy
- Loading branch information
Showing
11 changed files
with
122 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
/** | ||
* @testCase | ||
* @dataProvider ../../../sections.ini | ||
*/ | ||
|
||
namespace NextrasTests\Orm\Integration\Entity; | ||
|
||
use NextrasTests\Orm\DataTestCase; | ||
use NextrasTests\Orm\Log; | ||
use Tester\Assert; | ||
|
||
|
||
$dic = require_once __DIR__ . '/../../../bootstrap.php'; | ||
|
||
|
||
class EntityPkTest extends DataTestCase | ||
{ | ||
public function testDateTimeWithProxyPk() | ||
{ | ||
$log = new Log(); | ||
$log->id = $datetime = new \DateTimeImmutable('tomorrow'); | ||
$log->count = 3; | ||
$this->orm->persistAndFlush($log); | ||
|
||
$log->count = 5; | ||
$this->orm->persistAndFlush($log); | ||
|
||
$entry = $this->orm->logs->getById($datetime); | ||
Assert::true($entry !== null); | ||
} | ||
} | ||
|
||
|
||
$test = new EntityPkTest($dic); | ||
$test->run(); |
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
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,15 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace NextrasTests\Orm; | ||
|
||
use Nextras\Orm\Entity\Entity; | ||
|
||
|
||
/** | ||
* @property \DateTimeImmutable $id {primary-proxy} | ||
* @property \DateTimeImmutable $date {primary} | ||
* @property int $count | ||
*/ | ||
final class Log extends Entity | ||
{ | ||
} |
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,10 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace NextrasTests\Orm; | ||
|
||
use Nextras\Orm\Mapper\Mapper; | ||
|
||
|
||
final class LogsMapper extends Mapper | ||
{ | ||
} |
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,14 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace NextrasTests\Orm; | ||
|
||
use Nextras\Orm\Repository\Repository; | ||
|
||
|
||
final class LogsRepository extends Repository | ||
{ | ||
static function getEntityClassNames(): array | ||
{ | ||
return [Log::class]; | ||
} | ||
} |