-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from clementtalleu/feat/add_test_id
add test find by id
- Loading branch information
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
tests/Functionnal/Om/Repository/HashModel/HashIdentifierRepositoryTest.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,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Talleu\RedisOm\Tests\Functionnal\Om\Repository\HashModel; | ||
|
||
use Talleu\RedisOm\Om\RedisObjectManager; | ||
use Talleu\RedisOm\Tests\Fixtures\Hash\DummyHash; | ||
use Talleu\RedisOm\Tests\RedisAbstractTestCase; | ||
|
||
final class HashIdentifierRepositoryTest extends RedisAbstractTestCase | ||
{ | ||
public function testFindById() | ||
{ | ||
static::emptyRedis(); | ||
static::generateIndex(); | ||
static::loadRedisFixtures(); | ||
|
||
$objectManager = new RedisObjectManager(); | ||
$repository = $objectManager->getRepository(DummyHash::class); | ||
|
||
$collection = $repository->findBy(['id' => 1]); | ||
foreach ($collection as $dummy) { | ||
$this->assertInstanceOf(DummyHash::class, $dummy); | ||
$this->assertEquals($dummy->id, 1); | ||
} | ||
} | ||
|
||
public function testFindOneById() | ||
{ | ||
static::emptyRedis(); | ||
static::generateIndex(); | ||
static::loadRedisFixtures(); | ||
|
||
$objectManager = new RedisObjectManager(); | ||
$repository = $objectManager->getRepository(DummyHash::class); | ||
|
||
$objet = $repository->findOneBy(['id' => 2]); | ||
$this->assertEquals($objet->id, 2); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
tests/Functionnal/Om/Repository/JsonModel/JsonIdentifierRepositoryTest.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,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Talleu\RedisOm\Tests\Functionnal\Om\Repository\JsonModel; | ||
|
||
use Talleu\RedisOm\Om\RedisObjectManager; | ||
use Talleu\RedisOm\Tests\Fixtures\Json\DummyJson; | ||
use Talleu\RedisOm\Tests\RedisAbstractTestCase; | ||
|
||
final class JsonIdentifierRepositoryTest extends RedisAbstractTestCase | ||
{ | ||
public function testFindById() | ||
{ | ||
static::emptyRedis(); | ||
static::generateIndex(); | ||
static::loadRedisFixtures(DummyJson::class); | ||
|
||
$objectManager = new RedisObjectManager(); | ||
$repository = $objectManager->getRepository(DummyJson::class); | ||
|
||
$collection = $repository->findBy(['id' => 1]); | ||
foreach ($collection as $dummy) { | ||
$this->assertInstanceOf(DummyJson::class, $dummy); | ||
$this->assertEquals($dummy->id, 1); | ||
} | ||
} | ||
|
||
public function testFindOneById() | ||
{ | ||
static::emptyRedis(); | ||
static::generateIndex(); | ||
static::loadRedisFixtures(DummyJson::class); | ||
|
||
$objectManager = new RedisObjectManager(); | ||
$repository = $objectManager->getRepository(DummyJson::class); | ||
|
||
$objet = $repository->findOneBy(['id' => 2]); | ||
$this->assertEquals($objet->id, 2); | ||
} | ||
} |