mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-25 17:21:19 +02:00
23 lines
633 B
PHP
23 lines
633 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\More\Repository\Tests;
|
|
|
|
use DesignPatterns\More\Repository\MemoryStorage;
|
|
use DesignPatterns\More\Repository\Post;
|
|
use DesignPatterns\More\Repository\PostRepository;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class Repository extends TestCase
|
|
{
|
|
public function testCanPersistAndFindPost()
|
|
{
|
|
$repository = new PostRepository(new MemoryStorage());
|
|
$post = new Post(null, 'Repository Pattern', 'Design Patterns PHP');
|
|
|
|
$repository->save($post);
|
|
|
|
$this->assertEquals(1, $post->getId());
|
|
$this->assertEquals($post->getId(), $repository->findById(1)->getId());
|
|
}
|
|
}
|