Skip to content

Commit

Permalink
Merge pull request #63 from clementtalleu/feat/add_test_id
Browse files Browse the repository at this point in the history
add test find by id
  • Loading branch information
clementtalleu authored Jul 2, 2024
2 parents 61684a4 + a23d522 commit b272251
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
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);
}
}
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);
}
}

0 comments on commit b272251

Please sign in to comment.