|
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
|
|
|
class ModelTest_Comment extends \Sonata\NewsBundle\Model\Comment |
|
|
|
|
|
|
15
|
|
|
{ |
|
16
|
|
|
public function getId() |
|
17
|
|
|
{ |
|
18
|
|
|
} |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Class CommentTest. |
|
23
|
|
|
* |
|
24
|
|
|
* Tests the comment model |
|
25
|
|
|
*/ |
|
26
|
|
|
class CommentTest extends \PHPUnit_Framework_TestCase |
|
|
|
|
|
|
27
|
|
|
{ |
|
28
|
|
|
public function testSettersGetters() |
|
29
|
|
|
{ |
|
30
|
|
|
$date = new \DateTime(); |
|
31
|
|
|
|
|
32
|
|
|
$comment = new ModelTest_Comment(); |
|
33
|
|
|
$comment->setCreatedAt($date); |
|
34
|
|
|
$comment->setEmail('[email protected]'); |
|
35
|
|
|
$comment->setMessage('My message'); |
|
36
|
|
|
$comment->setName('My name'); |
|
37
|
|
|
$comment->setPost($this->getMock('Sonata\NewsBundle\Model\PostInterface')); |
|
38
|
|
|
$comment->setStatus(1); |
|
39
|
|
|
$comment->setUpdatedAt($date); |
|
40
|
|
|
$comment->setUrl('http://www.example.org'); |
|
41
|
|
|
|
|
42
|
|
|
$this->assertEquals($comment->getCreatedAt(), $date); |
|
43
|
|
|
$this->assertEquals($comment->getEmail(), '[email protected]'); |
|
44
|
|
|
$this->assertEquals($comment->getMessage(), 'My message'); |
|
45
|
|
|
$this->assertEquals($comment->getName(), 'My name'); |
|
46
|
|
|
$this->assertEquals($comment->getPost(), $this->getMock('Sonata\NewsBundle\Model\PostInterface')); |
|
47
|
|
|
$this->assertEquals($comment->getStatus(), 1); |
|
48
|
|
|
$this->assertEquals($comment->getUpdatedAt(), $date); |
|
49
|
|
|
$this->assertEquals($comment->getUrl(), 'http://www.example.org'); |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|
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.