| 1 |
<?php |
| 2 |
|
| 3 |
namespace QuadLayers\WP_Orm\Tests\Single\Repository; |
| 4 |
|
| 5 |
use PHPUnit\Framework\TestCase; |
| 6 |
use QuadLayers\WP_Orm\Repository\SingleRepositoryInterface; |
| 7 |
use QuadLayers\WP_Orm\Tests\Single\SingleEntityTest; |
| 8 |
|
| 9 |
class SingleRepositoryTest extends TestCase |
| 10 |
{ |
| 11 |
private SingleRepositoryInterface $repository; |
| 12 |
|
| 13 |
protected function setUp(): void |
| 14 |
{ |
| 15 |
$this->repository = $this->createMock(SingleRepositoryInterface::class); |
| 16 |
} |
| 17 |
|
| 18 |
public function testSave() |
| 19 |
{ |
| 20 |
|
| 21 |
$entity = new SingleEntityTest(); |
| 22 |
|
| 23 |
$testValue = $entity->getDefaults(); |
| 24 |
|
| 25 |
$this->repository |
| 26 |
->expects($this->once()) |
| 27 |
->method('create') |
| 28 |
->with($testValue) |
| 29 |
->willReturn(true); |
| 30 |
|
| 31 |
$this->repository->create($testValue); |
| 32 |
} |
| 33 |
|
| 34 |
public function testFind() |
| 35 |
{ |
| 36 |
|
| 37 |
$entity = new SingleEntityTest(); |
| 38 |
|
| 39 |
$this->repository |
| 40 |
->expects($this->once()) |
| 41 |
->method('find') |
| 42 |
->with(); |
| 43 |
|
| 44 |
$this->repository |
| 45 |
->expects($this->once()) |
| 46 |
->method('find') |
| 47 |
->willReturn($entity); |
| 48 |
|
| 49 |
$this->repository->find(); |
| 50 |
} |
| 51 |
} |
| 52 |
|