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
Showing
11 changed files
with
183 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/** | ||
* @testCase | ||
* @dataProvider ../../../sections.ini | ||
*/ | ||
|
||
namespace NextrasTests\Orm\Integration\Repository; | ||
|
||
use Mockery; | ||
use NextrasTests\Orm\DataTestCase; | ||
use Tester\Assert; | ||
|
||
$dic = require_once __DIR__ . '/../../../bootstrap.php'; | ||
|
||
|
||
class RepositorySTITest extends DataTestCase | ||
{ | ||
|
||
public function testSelect() | ||
{ | ||
\Tester\Environment::lock("integration-{$this->section}", TEMP_DIR); | ||
$thread = $this->orm->contents->findBy(['NextrasTests\Orm\Thread->id' => 1])->fetch(); | ||
Assert::type('NextrasTests\Orm\Thread', $thread); | ||
//Asset::fail('a'); | ||
} | ||
|
||
|
||
public function testRead() | ||
{ | ||
\Tester\Environment::lock("integration-{$this->section}", TEMP_DIR); | ||
$all = $this->orm->contents->findAll()->orderBy('id'); | ||
|
||
$thread = $all->fetch(); | ||
Assert::type('NextrasTests\Orm\Thread', $thread); | ||
|
||
$comment = $all->fetch(); | ||
Assert::type('NextrasTests\Orm\Comment', $comment); | ||
} | ||
|
||
} | ||
|
||
|
||
$test = new RepositorySTITest($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
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,22 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Nextras\ORM library. | ||
* | ||
* @license MIT | ||
* @link https://github.com/nextras/orm | ||
* @author Jan Skrasek | ||
*/ | ||
|
||
namespace NextrasTests\Orm; | ||
|
||
use Nextras\Orm\Entity\Entity; | ||
|
||
|
||
/** | ||
* @property-read string $type {default comment} | ||
* @property Thread|NULL $thread {m:1 Thread::$comments} | ||
*/ | ||
class Comment 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,18 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Nextras\ORM library. | ||
* | ||
* @license MIT | ||
* @link https://github.com/nextras/orm | ||
* @author Jan Skrasek | ||
*/ | ||
|
||
namespace NextrasTests\Orm; | ||
|
||
use Nextras\Orm\Mapper\Mapper; | ||
|
||
|
||
class ContentsMapper 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,38 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Nextras\ORM library. | ||
* | ||
* @license MIT | ||
* @link https://github.com/nextras/orm | ||
* @author Jan Skrasek | ||
*/ | ||
|
||
namespace NextrasTests\Orm; | ||
|
||
use Nextras\Orm\Repository\Repository; | ||
|
||
|
||
/** | ||
* @method Thread|Comment getById($id) | ||
*/ | ||
class ContentsRepository extends Repository | ||
{ | ||
|
||
public static function getEntityClassNames() | ||
{ | ||
return [ | ||
'NextrasTests\Orm\Comment', | ||
'NextrasTests\Orm\Thread', | ||
]; | ||
} | ||
|
||
|
||
public function getEntityClassName(array $data) | ||
{ | ||
return $data['type'] === 'comment' | ||
? 'NextrasTests\Orm\Comment' | ||
: 'NextrasTests\Orm\Thread'; | ||
} | ||
|
||
} |
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,23 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Nextras\ORM library. | ||
* | ||
* @license MIT | ||
* @link https://github.com/nextras/orm | ||
* @author Jan Skrasek | ||
*/ | ||
|
||
namespace NextrasTests\Orm; | ||
|
||
use Nextras\Orm\Entity\Entity; | ||
use Nextras\Orm\Relationships\ManyHasOne; | ||
|
||
|
||
/** | ||
* @property-read string $type {default thread} | ||
* @property ManyHasOne|Comment[] $comments {1:m Comment::$thread} | ||
*/ | ||
class Thread extends Entity | ||
{ | ||
} |