|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare( strict_types = 1 ); |
|
4
|
|
|
|
|
5
|
|
|
namespace WMDE\Fundraising\Frontend\DonatingContext\Tests\Unit\UseCases\ListComments; |
|
6
|
|
|
|
|
7
|
|
|
use WMDE\Fundraising\Frontend\DonatingContext\Domain\Repositories\CommentWithAmount; |
|
8
|
|
|
use WMDE\Fundraising\Frontend\DonatingContext\UseCases\ListComments\CommentList; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* @covers WMDE\Fundraising\Frontend\DonatingContext\UseCases\ListComments\CommentList |
|
12
|
|
|
* |
|
13
|
|
|
* @licence GNU GPL v2+ |
|
14
|
|
|
* @author Jeroen De Dauw < [email protected] > |
|
15
|
|
|
*/ |
|
16
|
|
|
class CommentListTest extends \PHPUnit_Framework_TestCase { |
|
17
|
|
|
|
|
18
|
|
|
public function testGivenNoArguments_constructorCreatesEmptyList() { |
|
19
|
|
|
$this->assertSame( [], ( new CommentList() )->toArray() ); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
public function testGivenOneComment_constructorCreatesListWithComment() { |
|
23
|
|
|
$comment = CommentWithAmount::newInstance() |
|
24
|
|
|
->setAuthorName( 'name0' ) |
|
25
|
|
|
->setCommentText( 'comment' ) |
|
26
|
|
|
->setDonationAmount( 42 ) |
|
27
|
|
|
->setDonationTime( new \DateTime( '1984-01-01' ) ); |
|
28
|
|
|
|
|
29
|
|
|
$this->assertSame( [ $comment ], ( new CommentList( $comment ) )->toArray() ); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function testGivenMultipleComments_constructorCreatesListWithAllComments() { |
|
33
|
|
|
$comment0 = CommentWithAmount::newInstance() |
|
34
|
|
|
->setAuthorName( 'name0' ) |
|
35
|
|
|
->setCommentText( 'comment' ) |
|
36
|
|
|
->setDonationAmount( 42 ) |
|
37
|
|
|
->setDonationTime( new \DateTime( '1984-01-01' ) ); |
|
38
|
|
|
|
|
39
|
|
|
$comment1 = CommentWithAmount::newInstance() |
|
40
|
|
|
->setAuthorName( 'name1' ) |
|
41
|
|
|
->setCommentText( 'comment' ) |
|
42
|
|
|
->setDonationAmount( 42 ) |
|
43
|
|
|
->setDonationTime( new \DateTime( '1984-01-01' ) ); |
|
44
|
|
|
|
|
45
|
|
|
$comment2 = CommentWithAmount::newInstance() |
|
46
|
|
|
->setAuthorName( 'name2' ) |
|
47
|
|
|
->setCommentText( 'comment' ) |
|
48
|
|
|
->setDonationAmount( 42 ) |
|
49
|
|
|
->setDonationTime( new \DateTime( '1984-01-01' ) ); |
|
50
|
|
|
|
|
51
|
|
|
$this->assertSame( |
|
52
|
|
|
[ $comment0, $comment1, $comment2 ], |
|
53
|
|
|
( new CommentList( $comment0, $comment1, $comment2 ) )->toArray() |
|
54
|
|
|
); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
} |
|
58
|
|
|
|