EventsBasedSnapshottingPolicyTests   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
c 1
b 0
f 1
lcom 1
cbo 5
dl 0
loc 26
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testShouldCreateSnapshot() 0 20 1
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
namespace Cubiche\Domain\EventSourcing\Tests\Units\Snapshot\Policy;
12
13
use Cubiche\Domain\EventSourcing\Snapshot\Policy\EventsBasedSnapshottingPolicy;
14
use Cubiche\Domain\EventSourcing\Tests\Fixtures\PostEventSourcedFactory;
15
use Cubiche\Domain\EventSourcing\Tests\Units\TestCase;
16
17
/**
18
 * EventsBasedSnapshottingPolicyTests class.
19
 *
20
 * Generated by TestGenerator on 2016-07-26 at 14:15:46.
21
 */
22
class EventsBasedSnapshottingPolicyTests extends TestCase
23
{
24
    /**
25
     * Test ShouldCreateSnapshot method.
26
     */
27
    public function testShouldCreateSnapshot()
28
    {
29
        $this
30
            ->given($policy = new EventsBasedSnapshottingPolicy())
31
            ->and(
32
                $post = PostEventSourcedFactory::create(
33
                    $this->faker->sentence,
34
                    $this->faker->paragraph
35
                )
36
            )
37
            ->then()
38
                ->boolean($policy->shouldCreateSnapshot($post))
39
                    ->isTrue()
40
                ->and()
41
                ->when($post->clearEvents())
42
                ->then()
43
                    ->boolean($policy->shouldCreateSnapshot($post))
44
                        ->isFalse()
45
        ;
46
    }
47
}
48