|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: davis |
|
5
|
|
|
* Date: 7/23/17 |
|
6
|
|
|
* Time: 7:25 PM |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace DavisPeixoto\BlogCore\Tests\Entity; |
|
10
|
|
|
|
|
11
|
|
|
use DateTime; |
|
12
|
|
|
use DavisPeixoto\BlogCore\Entity\Post; |
|
13
|
|
|
use DavisPeixoto\BlogCore\Entity\Author; |
|
14
|
|
|
use DavisPeixoto\BlogCore\Entity\Tag; |
|
15
|
|
|
use PHPUnit_Framework_TestCase; |
|
16
|
|
|
use Ramsey\Uuid\Uuid; |
|
17
|
|
|
|
|
18
|
|
|
class TestPost extends PHPUnit_Framework_TestCase |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @param $uuid |
|
22
|
|
|
* @param $title |
|
23
|
|
|
* @param $body |
|
24
|
|
|
* @param $author |
|
25
|
|
|
* @param $tags |
|
26
|
|
|
* @param $publishDate |
|
27
|
|
|
* @param $expected |
|
28
|
|
|
* @param $message |
|
29
|
|
|
* @dataProvider postConstructor |
|
30
|
|
|
*/ |
|
31
|
|
|
public function testConstructor($uuid, $title, $body, $author, $tags, $publishDate, $expected, $message) |
|
32
|
|
|
{ |
|
33
|
|
|
$post = new Post($uuid, $title, $body, $author, $tags, $publishDate); |
|
34
|
|
|
$this->assertInstanceOf($expected, $post, $message); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function postConstructor() |
|
38
|
|
|
{ |
|
39
|
|
|
return [ |
|
40
|
|
|
[Uuid::uuid4(), 'A Post', 'Lorem ipsum', new Author(Uuid::uuid4(), 'Davis', '[email protected]', 'Some string', new DateTime()), [], null, Post::class, 'no tags, no publish date'], |
|
41
|
|
|
[Uuid::uuid4(), 'A Post', 'Lorem ipsum', new Author(Uuid::uuid4(), 'Davis', '[email protected]', 'Some string', new DateTime()), [new Tag(Uuid::uuid4(),'tag1'), new Tag(Uuid::uuid4(),'tag2')], null, Post::class, 'have tags, unpublished'], |
|
|
|
|
|
|
42
|
|
|
[Uuid::uuid4(), 'A Post', 'Lorem ipsum', new Author(Uuid::uuid4(), 'Davis', '[email protected]', 'Some string', new DateTime()), [], new DateTime(), Post::class, 'no tags, published'], |
|
43
|
|
|
[Uuid::uuid4(), 'A Post', 'Lorem ipsum', new Author(Uuid::uuid4(), 'Davis', '[email protected]', 'Some string', new DateTime()), [new Tag(Uuid::uuid4(),'tag1'), new Tag(Uuid::uuid4(),'tag2')], new DateTime(), Post::class, 'tags, published (most common scenario)'] |
|
|
|
|
|
|
44
|
|
|
]; |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
|
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.