Completed
Push — master ( 052020...96a045 )
by Davis
02:17
created

TestAuthor::testConstructor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 5
rs 9.4285
c 1
b 1
f 0
cc 1
eloc 3
nc 1
nop 7
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