Skip to content

Commit

Permalink
Add red #44 test
Browse files Browse the repository at this point in the history
  • Loading branch information
koriym committed Feb 21, 2023
1 parent ef3dda2 commit 31a8c64
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/DbQueryModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Ray\MediaQuery\Entity\TodoConstruct;
use Ray\MediaQuery\Exception\InvalidPerPageVarNameException;
use Ray\MediaQuery\Exception\PerPageNotIntTypeException;
use Ray\MediaQuery\Fake\Queries\TodoEntityNullableInterface;
use Ray\MediaQuery\Fake\Queries\TodoFactoryInterface;
use Ray\MediaQuery\Fake\Queries\TodoFactoryUnionInterface;
use Ray\MediaQuery\Queries\DynamicPerPageInterface;
Expand Down Expand Up @@ -53,6 +54,7 @@ protected function setUp(): void
PromiseItemInterface::class,
PromiseListInterface::class,
TodoEntityInterface::class,
TodoEntityNullableInterface::class,
TodoConstcuctEntityInterface::class,
DynamicPerPageInterface::class,
DynamicPerPageInvalidInterface::class,
Expand Down Expand Up @@ -145,6 +147,17 @@ public function testEntity(): void
$this->assertInstanceOf(Todo::class, $item);
}

public function testEntityNullable(): void
{
/** @var TodoEntityInterface $todoList */
$todoList = $this->injector->getInstance(TodoEntityNullableInterface::class);
$list = $todoList->getList();
$this->assertInstanceOf(Todo::class, $list[0]);
$this->assertSame('run', $list[0]->title);
$item = $todoList->getItem('1');
$this->assertInstanceOf(Todo::class, $item);
}

public function testEntityWithConstructor(): void
{
/** @var TodoEntityInterface $todoList */
Expand Down
20 changes: 20 additions & 0 deletions tests/Fake/Queries/TodoEntityNullableInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace Ray\MediaQuery\Fake\Queries;

use Ray\MediaQuery\Annotation\DbQuery;
use Ray\MediaQuery\Entity\Todo;

interface TodoEntityNullableInterface
{
#[DbQuery('todo_item')]
public function getItem(string $id): ?Todo;

#[DbQuery('todo_list')]
/**
* @return array<Todo>
*/
public function getList(): ?array;
}

0 comments on commit 31a8c64

Please sign in to comment.