2016-10-19 17:54:41 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once dirname(dirname(__FILE__)) . '/setup.php';
|
|
|
|
|
|
|
|
use AppBundle\Model\Note;
|
|
|
|
|
|
|
|
class NoteTest extends BaseTestCase {
|
|
|
|
|
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCanSaveAndLoad() {
|
|
|
|
$note = new Note();
|
2017-01-08 01:35:17 +02:00
|
|
|
$note->setDiffableField('title', 'the title');
|
|
|
|
$note->setDiffableField('body', 'the body');
|
2016-10-19 17:54:41 +02:00
|
|
|
$note->save();
|
|
|
|
|
|
|
|
$note = $note->find($note->id);
|
|
|
|
$this->assertNotNull($note);
|
2017-01-08 01:35:17 +02:00
|
|
|
$this->assertEquals('the title', $note->diffableField('title'));
|
|
|
|
$this->assertEquals('the body', $note->diffableField('body'));
|
2016-10-19 17:54:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testFromToPublicArray() {
|
|
|
|
$a = array(
|
|
|
|
'title' => 'the title',
|
|
|
|
'body' => 'the body',
|
|
|
|
);
|
|
|
|
$note = new Note();
|
|
|
|
$note->fromPublicArray($a);
|
|
|
|
$note->save();
|
|
|
|
|
|
|
|
$note = $note::find($note->id);
|
|
|
|
$b = $note->toPublicArray();
|
|
|
|
|
|
|
|
$this->assertEquals('the title', $b['title']);
|
|
|
|
$this->assertEquals('the body', $b['body']);
|
|
|
|
$this->assertArrayHasKey('rev_id', $b);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|