|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sonata Project package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Thomas Rabaix <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Sonata\NewsBundle\Tests\Model; |
|
13
|
|
|
|
|
14
|
|
|
use PHPUnit\Framework\TestCase; |
|
15
|
|
|
use Sonata\NewsBundle\Model\Post; |
|
16
|
|
|
|
|
17
|
|
|
class ModelTest_Post extends Post |
|
|
|
|
|
|
18
|
|
|
{ |
|
19
|
|
|
public function getId() |
|
20
|
|
|
{ |
|
21
|
|
|
} |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Tests the post model. |
|
26
|
|
|
*/ |
|
27
|
|
|
class PostTest extends TestCase |
|
|
|
|
|
|
28
|
|
|
{ |
|
29
|
|
|
public function testSettersGetters() |
|
30
|
|
|
{ |
|
31
|
|
|
$date = new \DateTime(); |
|
32
|
|
|
|
|
33
|
|
|
$post = new ModelTest_Post(); |
|
34
|
|
|
$post->setAbstract('My abstract content'); |
|
35
|
|
|
$post->setAuthor('My author'); |
|
|
|
|
|
|
36
|
|
|
$post->setCollection($this->createMock('Sonata\ClassificationBundle\Model\CollectionInterface')); |
|
37
|
|
|
$post->setCommentsCloseAt($date); |
|
38
|
|
|
$post->setCommentsCount(5); |
|
39
|
|
|
$post->setCommentsDefaultStatus(1); |
|
40
|
|
|
$post->setCommentsEnabled(true); |
|
41
|
|
|
$post->setContent('My content'); |
|
42
|
|
|
$post->setContentFormatter('markdown'); |
|
43
|
|
|
$post->setCreatedAt($date); |
|
44
|
|
|
$post->setEnabled(true); |
|
45
|
|
|
$post->setPublicationDateStart($date); |
|
46
|
|
|
$post->setRawContent('My raw content'); |
|
47
|
|
|
$post->setTags($this->createMock('Sonata\ClassificationBundle\Model\TagInterface')); |
|
48
|
|
|
$post->setTitle('My title'); |
|
49
|
|
|
$post->setSlug('my-post-slug'); |
|
50
|
|
|
$post->setUpdatedAt($date); |
|
51
|
|
|
|
|
52
|
|
|
$this->assertEquals($post->getAbstract(), 'My abstract content'); |
|
53
|
|
|
$this->assertEquals($post->getAuthor(), 'My author'); |
|
54
|
|
|
$this->assertEquals($post->getCollection(), $this->createMock('Sonata\ClassificationBundle\Model\CollectionInterface')); |
|
55
|
|
|
$this->assertEquals($post->getCommentsCloseAt(), $date); |
|
56
|
|
|
$this->assertEquals($post->getCommentsCount(), 5); |
|
57
|
|
|
$this->assertEquals($post->getCommentsDefaultStatus(), 1); |
|
58
|
|
|
$this->assertEquals($post->getCommentsEnabled(), true); |
|
59
|
|
|
$this->assertEquals($post->getContent(), 'My content'); |
|
60
|
|
|
$this->assertEquals($post->getContentFormatter(), 'markdown'); |
|
61
|
|
|
$this->assertEquals($post->getCreatedAt(), $date); |
|
62
|
|
|
$this->assertEquals($post->getEnabled(), true); |
|
63
|
|
|
$this->assertEquals($post->getPublicationDateStart(), $date); |
|
64
|
|
|
$this->assertEquals($post->getRawContent(), 'My raw content'); |
|
65
|
|
|
$this->assertEquals($post->getSlug(), 'my-post-slug'); |
|
66
|
|
|
$this->assertEquals($post->getTags(), $this->createMock('Sonata\ClassificationBundle\Model\TagInterface')); |
|
67
|
|
|
$this->assertEquals($post->getTitle(), 'My title'); |
|
68
|
|
|
$this->assertEquals($post->getUpdatedAt(), $date); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
Classes in PHP are usually named in CamelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.
Thus the name database provider becomes
DatabaseProvider.