Code Duplication    Length = 36-39 lines in 4 locations

src/PhpValueObjects/Tests/Geography/LanguageCodeValueObjectTest.php 1 location

@@ 8-44 (lines=37) @@
5
use PhpValueObjects\Geography\Exception\InvalidLanguageCodeException;
6
use PhpValueObjects\Tests\BaseUnitTestCase;
7
8
class LanguageCodeValueObjectTest extends BaseUnitTestCase
9
{
10
    /**
11
     * @test
12
     */
13
    public function itShouldReturnLanguageCode()
14
    {
15
        $language = $this->faker()->languageCode;
16
17
        $langVO = new LanguageCodeValueObject($language);
18
19
        $this->assertSame($language, $langVO->value());
20
        $this->assertSame($language, $langVO->__toString());
21
    }
22
23
    /**
24
     * @return array
25
     */
26
    public function invalidLanguageCodeProvider()
27
    {
28
        return [
29
            [null],
30
            [$this->faker()->address],
31
            [$this->faker()->numberBetween()],
32
        ];
33
    }
34
    /**
35
     * @test
36
     * @dataProvider invalidLanguageCodeProvider
37
     */
38
    public function isShouldThrowsException($data)
39
    {
40
        $this->expectException(InvalidLanguageCodeException::class);
41
42
        new LanguageCodeValueObject($data);
43
    }
44
}
45

src/PhpValueObjects/Tests/Identity/EmailValueObjectTest.php 1 location

@@ 10-48 (lines=39) @@
7
use PhpValueObjects\Identity\Exception\InvalidEmailException;
8
use PhpValueObjects\Tests\BaseUnitTestCase;
9
10
class EmailValueObjectTest extends BaseUnitTestCase
11
{
12
    /**
13
     * @test
14
     */
15
    public function itShouldReturnEmail()
16
    {
17
        $email = $this->faker()->email;
18
19
        $emailVO = new EmailValueObject($email);
20
21
        $this->assertSame($email, $emailVO->value());
22
        $this->assertSame($email, $emailVO->__toString());
23
    }
24
25
    /**
26
     * @return array
27
     */
28
    public function invalidEmailProvider()
29
    {
30
        return [
31
            [null],
32
            [$this->faker()->numberBetween()],
33
            [$this->faker()->address],
34
        ];
35
    }
36
37
    /**
38
     * @test
39
     *
40
     * @dataProvider invalidEmailProvider
41
     */
42
    public function itShouldThrowsException($data)
43
    {
44
        $this->expectException(InvalidEmailException::class);
45
46
        new EmailValueObject($data);
47
    }
48
}
49

src/PhpValueObjects/Tests/Identity/UuidValueObjectTest.php 1 location

@@ 8-43 (lines=36) @@
5
use PhpValueObjects\Identity\Exception\InvalidUuidException;
6
use PhpValueObjects\Tests\BaseUnitTestCase;
7
8
class UuidValueObjectTest extends BaseUnitTestCase
9
{
10
    /**
11
     * @test
12
     */
13
    public function itShouldReturnUuid()
14
    {
15
        $uuid = $this->faker()->uuid;
16
17
        $uuidVO = new UuidValueObject($uuid);
18
19
        $this->assertSame($uuid, $uuidVO->value());
20
        $this->assertSame($uuid, $uuidVO->__toString());
21
    }
22
23
    public function invalidUuidProvider()
24
    {
25
        return [
26
            [null],
27
            [$this->faker()->numberBetween()],
28
            [$this->faker()->address],
29
        ];
30
    }
31
32
    /**
33
     * @test
34
     *
35
     * @dataProvider invalidUuidProvider
36
     */
37
    public function itShouldThrowsException($data)
38
    {
39
        $this->expectException(InvalidUuidException::class);
40
41
        new UuidValueObject($data);
42
    }
43
}
44

src/PhpValueObjects/Tests/Network/Ipv4ValueObjectTest.php 1 location

@@ 8-46 (lines=39) @@
5
use PhpValueObjects\Network\Exception\InvalidIpv4Exception;
6
use PhpValueObjects\Tests\BaseUnitTestCase;
7
8
class Ipv4ValueObjectTest extends BaseUnitTestCase
9
{
10
    /**
11
     * @test
12
     */
13
    public function itShouldReturnIpv4Address()
14
    {
15
16
        $ipAddress = $this->faker()->ipv4;
17
18
        $ipv4 = new Ipv4ValueObject($ipAddress);
19
20
        $this->assertSame($ipAddress, $ipv4->value());
21
        $this->assertSame($ipAddress, $ipv4->__toString());
22
    }
23
24
    /**
25
     * @return array
26
     */
27
    public function invalidIpv4AddressProvider()
28
    {
29
        return [
30
            [null],
31
            [$this->faker()->numberBetween()],
32
            [$this->faker()->ipv6]
33
        ];
34
    }
35
36
    /**
37
     * @test
38
     * @dataProvider invalidIpv4AddressProvider
39
     */
40
    public function itShouldThrowsException($data)
41
    {
42
        $this->expectException(InvalidIpv4Exception::class);
43
44
        new Ipv4ValueObject($data);
45
    }
46
}
47