Passed
Push — issue#767 ( dafcb3...15eee1 )
by Guilherme
05:07
created

StatisticsTest::testStatistics()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 18
nc 1
nop 0
dl 0
loc 22
rs 9.2
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace LoginCidadao\StatsBundle\Tests\Entity;
12
13
use LoginCidadao\StatsBundle\Entity\Statistics;
14
15
class StatisticsTest extends \PHPUnit_Framework_TestCase
16
{
17
    public function testStatistics()
18
    {
19
        $date = '2018-01-01';
20
        $time = '01:02:03';
21
        $index = 'index';
22
        $key = 'key';
23
        $timestamp = \DateTime::createFromFormat('Y-m-d H:i:s', "{$date} {$time}");
24
        $value = 321;
25
26
        $statistics = (new Statistics())
27
            ->setIndex($index)
28
            ->setKey($key)
29
            ->setTimestamp($timestamp)
0 ignored issues
show
Bug introduced by
It seems like $timestamp can also be of type false; however, parameter $timestamp of LoginCidadao\StatsBundle...tistics::setTimestamp() does only seem to accept DateTime, maybe add an additional type check? ( Ignorable by Annotation )

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

29
            ->setTimestamp(/** @scrutinizer ignore-type */ $timestamp)
Loading history...
30
            ->setValue($value);
31
32
        $this->assertNull($statistics->getId());
33
        $this->assertSame($index, $statistics->getIndex());
34
        $this->assertSame($key, $statistics->getKey());
35
        $this->assertSame($timestamp, $statistics->getTimestamp());
36
        $this->assertSame($value, $statistics->getValue());
37
        $this->assertSame($date, $statistics->getDate());
38
        $this->assertSame("{$date} {$time}", $statistics->getDateTime());
39
    }
40
}
41