szurubooru/tests/Dao/PostNoteDaoTest.php

45 lines
1 KiB
PHP
Raw Normal View History

2014-10-25 12:27:04 +02:00
<?php
namespace Szurubooru\Tests\Dao;
2014-10-25 23:04:43 +02:00
use Szurubooru\Dao\PostDao;
2014-10-25 12:27:04 +02:00
use Szurubooru\Dao\PostNoteDao;
use Szurubooru\Entities\PostNote;
use Szurubooru\Tests\AbstractDatabaseTestCase;
final class PostNoteDaoTest extends AbstractDatabaseTestCase
{
2014-10-25 23:04:43 +02:00
private $postDaoMock;
public function setUp()
{
parent::setUp();
$this->postDaoMock = $this->mock(PostDao::class);
}
2014-10-25 12:27:04 +02:00
public function testSettingValues()
{
$expected = new PostNote();
$expected->setPostId(5);
$expected->setLeft(5);
$expected->setTop(10);
$expected->setWidth(50);
$expected->setHeight(50);
$expected->setText('text');
$postNoteDao = $this->getPostNoteDao();
$postNoteDao->save($expected);
$actual = $postNoteDao->findById($expected->getId());
$this->assertEntitiesEqual($actual, $expected);
2014-10-25 23:04:43 +02:00
$this->postDaoMock->expects($this->once())->method('findById')->with(5)->willReturn('lazy post');
$this->assertEquals('lazy post', $actual->getPost());
2014-10-25 12:27:04 +02:00
}
private function getPostNoteDao()
{
2014-10-25 23:04:43 +02:00
return new PostNoteDao(
$this->databaseConnection,
$this->postDaoMock);
2014-10-25 12:27:04 +02:00
}
}