CommandTest::testToNative()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 8
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the daikon-cqrs/event-sourcing project.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Daikon\Tests\EventSourcing;
10
11
use Daikon\Tests\EventSourcing\Aggregate\Mock\BakePizza;
12
use PHPUnit\Framework\TestCase;
13
14
final class CommandTest extends TestCase
15
{
16 1
    public function testFromNative(): void
17
    {
18 1
        $ingredients = ['mushrooms', 'tomatoes', 'onions'];
19 1
        $bakePizza = BakePizza::fromNative([
20 1
            'pizzaId' => 'pizza-42-6-23',
21 1
            'ingredients' => $ingredients
22
        ]);
23 1
        $this->assertEquals('pizza-42-6-23', $bakePizza->getPizzaId());
0 ignored issues
show
Bug introduced by
It seems like getPizzaId() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
        $this->assertEquals('pizza-42-6-23', $bakePizza->/** @scrutinizer ignore-call */ getPizzaId());
Loading history...
24 1
        $this->assertEquals(0, $bakePizza->getKnownAggregateRevision()->toNative());
0 ignored issues
show
Bug introduced by
It seems like getKnownAggregateRevision() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        $this->assertEquals(0, $bakePizza->/** @scrutinizer ignore-call */ getKnownAggregateRevision()->toNative());
Loading history...
25 1
        $this->assertEquals($ingredients, $bakePizza->getIngredients()->toNative());
0 ignored issues
show
Bug introduced by
It seems like getIngredients() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
        $this->assertEquals($ingredients, $bakePizza->/** @scrutinizer ignore-call */ getIngredients()->toNative());
Loading history...
26 1
    }
27
28 1
    public function testToNative(): void
29
    {
30
        $bakePizzaArray = [
31 1
            'pizzaId' => 'pizza-42-6-23',
32
            'revision' => 0,
33
            'ingredients' => ['mushrooms', 'tomatoes', 'onions']
34
        ];
35 1
        $this->assertEquals($bakePizzaArray, BakePizza::fromNative($bakePizzaArray)->toNative());
36 1
    }
37
}
38