Completed
Push — master ( 84505b...5678fc )
by Ivannis Suárez
02:56
created

ProjectionTests::testSetAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.2
c 0
b 0
f 0
cc 1
eloc 17
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\Projector;
13
14
use Cubiche\Domain\EventSourcing\Projector\Action;
15
use Cubiche\Domain\EventSourcing\Projector\Projection;
16
use Cubiche\Domain\EventSourcing\Tests\Fixtures\ReadModel\PublishedPost;
17
use Cubiche\Domain\EventSourcing\Tests\Units\TestCase;
18
use Cubiche\Domain\Model\Tests\Fixtures\PostId;
19
20
/**
21
 * ProjectionTests class.
22
 *
23
 * Generated by TestGenerator on 2017-05-05 at 11:37:18.
24
 */
25
class ProjectionTests extends TestCase
26
{
27
    /**
28
     * Test create.
29
     */
30 View Code Duplication
    public function testCreate()
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...
31
    {
32
        $this
33
            ->given(
34
                $readModel = new PublishedPost(
35
                    PostId::fromNative(md5(rand())),
36
                    $this->faker->title,
37
                    $this->faker->text()
0 ignored issues
show
Unused Code introduced by
The call to PublishedPost::__construct() has too many arguments starting with $this->faker->text().

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
38
                )
39
            )
40
            ->and($action = Action::NONE())
41
            ->when($projection = new Projection($readModel, $action))
42
            ->then()
43
                ->object($projection->readModel())
44
                    ->isEqualTo($readModel)
45
                ->object($projection->action())
46
                    ->isEqualTo($action)
47
        ;
48
    }
49
50
    /**
51
     * Test SetReadModel method.
52
     */
53
    public function testSetReadModel()
54
    {
55
        $this
56
            ->given(
57
                $readModel = new PublishedPost(
58
                    PostId::fromNative(md5(rand())),
59
                    $this->faker->title,
60
                    $this->faker->text()
0 ignored issues
show
Unused Code introduced by
The call to PublishedPost::__construct() has too many arguments starting with $this->faker->text().

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
61
                )
62
            )
63
            ->and(
64
                $newReadModel = new PublishedPost(
65
                    PostId::fromNative(md5(rand())),
66
                    $this->faker->title,
67
                    $this->faker->text()
0 ignored issues
show
Unused Code introduced by
The call to PublishedPost::__construct() has too many arguments starting with $this->faker->text().

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
68
                )
69
            )
70
            ->and($action = Action::NONE())
71
            ->when($projection = new Projection($readModel, $action))
72
            ->then()
73
                ->object($projection->readModel())
74
                    ->isEqualTo($readModel)
75
                ->and()
76
                ->when($projection->setReadModel($newReadModel))
77
                ->then()
78
                    ->object($projection->readModel())
79
                        ->isEqualTo($newReadModel)
80
        ;
81
    }
82
83
    /**
84
     * Test SetAction method.
85
     */
86
    public function testSetAction()
87
    {
88
        $this
89
            ->given(
90
                $readModel = new PublishedPost(
91
                    PostId::fromNative(md5(rand())),
92
                    $this->faker->title,
93
                    $this->faker->text()
0 ignored issues
show
Unused Code introduced by
The call to PublishedPost::__construct() has too many arguments starting with $this->faker->text().

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
94
                )
95
            )
96
            ->and($action = Action::NONE())
97
            ->when($projection = new Projection($readModel, $action))
98
            ->then()
99
                ->object($projection->action())
100
                    ->isEqualTo($action)
101
                ->and()
102
                ->when($projection->setAction(Action::REMOVE()))
103
                ->then()
104
                    ->object($projection->action())
105
                        ->isEqualTo(Action::REMOVE())
106
        ;
107
    }
108
}
109