Completed
Push — master ( 0141b8...171c3a )
by Ivannis Suárez
04:55
created

SnapshotTests::testSnapshotName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 16
Ratio 100 %

Importance

Changes 0
Metric Value
dl 16
loc 16
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the Cubiche/EventSourcing component.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Cubiche\Domain\EventSourcing\Tests\Units\Snapshot;
13
14
use Cubiche\Domain\EventSourcing\Snapshot\Snapshot;
15
use Cubiche\Domain\EventSourcing\Tests\Fixtures\PostEventSourcedFactory;
16
use Cubiche\Domain\EventSourcing\Tests\Units\TestCase;
17
use Cubiche\Domain\EventSourcing\Versioning\Version;
18
19
/**
20
 * SnapshotTests class.
21
 *
22
 * Generated by TestGenerator on 2016-06-28 at 14:36:54.
23
 */
24
class SnapshotTests extends TestCase
25
{
26
    /**
27
     * Test snapshotName method.
28
     */
29 View Code Duplication
    public function testSnapshotName()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
    {
31
        $this
32
            ->given(
33
                $post = PostEventSourcedFactory::create(
34
                    $this->faker->sentence,
35
                    $this->faker->paragraph
36
                )
37
            )
38
            ->and($snapshotName = 'Posts-'.$post->id()->toNative())
39
            ->and($snapshot = new Snapshot($snapshotName, $post))
40
            ->then()
41
                ->string($snapshot->snapshotName())
42
                    ->isEqualTo($snapshotName)
43
        ;
44
    }
45
46
    /**
47
     * Test Aggregate method.
48
     */
49 View Code Duplication
    public function testAggregate()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
50
    {
51
        $this
52
            ->given(
53
                $post = PostEventSourcedFactory::create(
54
                    $this->faker->sentence,
55
                    $this->faker->paragraph
56
                )
57
            )
58
            ->and($snapshotName = 'Posts-'.$post->id()->toNative())
59
            ->and($snapshot = new Snapshot($snapshotName, $post))
60
            ->then()
61
                ->object($snapshot->aggregate())
62
                    ->isEqualTo($post)
63
        ;
64
    }
65
66
    /**
67
     * Test Version method.
68
     */
69
    public function testVersion()
70
    {
71
        $this
72
            ->given(
73
                $post = PostEventSourcedFactory::create(
74
                    $this->faker->sentence,
75
                    $this->faker->paragraph
76
                )
77
            )
78
            ->and($post->setVersion(345))
79
            ->and($snapshotName = 'Posts-'.$post->id()->toNative())
80
            ->and($snapshot = new Snapshot($snapshotName, $post))
81
            ->then()
82
                ->integer($snapshot->version())
83
                    ->isEqualTo($post->version())
84
                    ->isEqualTo(345)
85
        ;
86
    }
87
88
    /**
89
     * Test CreatedAt method.
90
     */
91 View Code Duplication
    public function testCreatedAt()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
92
    {
93
        $this
94
            ->given(
95
                $post = PostEventSourcedFactory::create(
96
                    $this->faker->sentence,
97
                    $this->faker->paragraph
98
                )
99
            )
100
            ->and($snapshotName = 'Posts-'.$post->id()->toNative())
101
            ->and($snapshot = new Snapshot($snapshotName, $post))
102
            ->then()
103
                ->object($snapshot->createdAt())
104
                    ->isInstanceOf(\DateTime::class)
105
        ;
106
    }
107
}
108