DatetimeTest::testEventsDatetime()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 12

Duplication

Lines 18
Ratio 100 %

Importance

Changes 0
Metric Value
dl 18
loc 18
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 12
nc 1
nop 0
1
<?php
2
3
namespace Spiral\Tests\Statistics;
4
5
use Spiral\Statistics\Database\Event;
6
use Spiral\Statistics\Database\Occurrence;
7
use Spiral\Tests\BaseTest;
8
9
class DatetimeTest extends BaseTest
10
{
11
    /**
12
     * Default datetime is NOW for track event
13
     */
14 View Code Duplication
    public function testEventDatetime()
1 ignored issue
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...
15
    {
16
        $track = $this->getTrack();
17
18
        $this->assertCount(0, $this->orm->source(Occurrence::class));
19
        $this->assertCount(0, $this->orm->source(Event::class));
20
21
        $datetime = new \DateTime('now');
22
        $track->event('some-event', 1.23);
23
        $track->event('some-event2', 2.34, $datetime);
24
25
        $this->assertCount(1, $this->orm->source(Occurrence::class));
26
        $this->assertCount(2, $this->orm->source(Event::class));
27
    }
28
29
    /**
30
     * Default datetime is NOW for track events
31
     */
32 View Code Duplication
    public function testEventsDatetime()
1 ignored issue
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...
33
    {
34
        $track = $this->getTrack();
35
36
        $this->assertCount(0, $this->orm->source(Occurrence::class));
37
        $this->assertCount(0, $this->orm->source(Event::class));
38
39
        $datetime = new \DateTime('now');
40
        $track->events([
41
            'some-event' => 1.23
42
        ]);
43
        $track->events([
44
            'some-event2' => 2.34
45
        ], $datetime);
46
47
        $this->assertCount(1, $this->orm->source(Occurrence::class));
48
        $this->assertCount(2, $this->orm->source(Event::class));
49
    }
50
}