FullCalendarHelperTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 13
dl 0
loc 46
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 1
A testParseStartDateTime() 0 6 1
A testParseEndDateTime() 0 6 1
1
<?php
2
3
/*
4
 * This file is part of the core-bundle package.
5
 *
6
 * (c) 2022 WEBEWEB
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 WBW\Bundle\CoreBundle\Tests\Helper\Assets;
13
14
use DateTime;
15
use Symfony\Component\HttpFoundation\Request;
16
use WBW\Bundle\CoreBundle\Helper\Assets\FullCalendarHelper;
17
use WBW\Bundle\CoreBundle\Tests\AbstractTestCase;
18
19
/**
20
 * Full Calendar helper test.
21
 *
22
 * @author webeweb <https://github.com/webeweb>
23
 * @package WBW\Bundle\CoreBundle\Tests\Helper\Assets
24
 */
25
class FullCalendarHelperTest extends AbstractTestCase {
26
27
    /**
28
     * Request.
29
     *
30
     * @var Request
31
     */
32
    private $request;
33
34
    /**
35
     * {@inheritDoc}
36
     */
37
    protected function setUp(): void {
38
        parent::setUp();
39
40
        // Set a Request mock.
41
        $this->request = new Request([
42
            "start" => "2013-12-01T00:00:00-05:00",
43
            "end"   => "2014-01-12T00:00:00-05:00",
44
        ], [], [], [], [], [], ["REQUEST_METHOD" => "GET"]);
0 ignored issues
show
Bug introduced by
array('REQUEST_METHOD' => 'GET') of type array<string,string> is incompatible with the type null|resource|string expected by parameter $content of Symfony\Component\HttpFo...\Request::__construct(). ( Ignorable by Annotation )

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

44
        ], [], [], [], [], [], /** @scrutinizer ignore-type */ ["REQUEST_METHOD" => "GET"]);
Loading history...
45
    }
46
47
    /**
48
     * Test parseEndDateTime()
49
     *
50
     * @return void
51
     */
52
    public function testParseEndDateTime(): void {
53
54
        $res = FullCalendarHelper::parseEndDateTime($this->request);
55
        $this->assertInstanceOf(DateTime::class, $res);
56
57
        $this->assertEquals("2014-01-12 00:00", $res->format("Y-m-d H:i"));
58
    }
59
60
    /**
61
     * Test parseStartDateTime()
62
     *
63
     * @return void
64
     */
65
    public function testParseStartDateTime(): void {
66
67
        $res = FullCalendarHelper::parseStartDateTime($this->request);
68
        $this->assertInstanceOf(DateTime::class, $res);
69
70
        $this->assertEquals("2013-12-01 00:00", $res->format("Y-m-d H:i"));
71
    }
72
}
73