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\Author; |
13
|
|
|
use PHPUnit_Framework_TestCase; |
14
|
|
|
use Ramsey\Uuid\Uuid; |
15
|
|
|
|
16
|
|
|
class TestAuthor extends PHPUnit_Framework_TestCase |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @param $uuid |
20
|
|
|
* @param $name |
21
|
|
|
* @param $email |
22
|
|
|
* @param $bio |
23
|
|
|
* @param $birthdate |
24
|
|
|
* @param $expected |
25
|
|
|
* @param $message |
26
|
|
|
* @dataProvider authorConstructorProvider |
27
|
|
|
*/ |
28
|
|
|
public function testConstructor($uuid, $name, $email, $bio, $birthdate, $expected, $message) |
29
|
|
|
{ |
30
|
|
|
$author = new Author($uuid, $name, $email, $bio, $birthdate); |
31
|
|
|
$this->assertInstanceOf($expected, $author, $message); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param Author $author |
36
|
|
|
* @param $newEmailAddress |
37
|
|
|
* @param $expected |
38
|
|
|
* @param $message |
39
|
|
|
* @dataProvider emailProvider |
40
|
|
|
*/ |
41
|
|
|
public function testEmailShouldBeValid(Author $author, $newEmailAddress, $expected, $message) |
42
|
|
|
{ |
43
|
|
|
$author->setEmail($newEmailAddress); |
44
|
|
|
$email = $author->getEmail(); |
45
|
|
|
$this->assertEquals($expected, $email, $message); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function authorConstructorProvider() |
49
|
|
|
{ |
50
|
|
|
return [ |
51
|
|
|
[Uuid::uuid4(), 'Davis', '[email protected]', 'Some string', new DateTime(), Author::class, 'Regular test'], |
52
|
|
|
]; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function emailProvider() |
56
|
|
|
{ |
57
|
|
|
$author = new Author(Uuid::uuid4(), 'Davis', '[email protected]', 'Foo', new DateTime()); |
58
|
|
|
|
59
|
|
|
return [ |
60
|
|
|
[$author, 'example.org', '[email protected]', 'Negative test'], |
61
|
|
|
[$author, '[email protected]', '[email protected]', 'Positive test'] |
62
|
|
|
]; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|