TimestampTypeTest::assertForm()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php declare(strict_types = 1);
2
3
/*
4
 * This file is part of the Bukashk0zzzTimestampTypeBundle
5
 *
6
 * (c) Denis Golubovskiy <[email protected]>
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 Bukashk0zzz\TimestampTypeBundle\Tests;
13
14
use Bukashk0zzz\TimestampTypeBundle\Form\Type\TimestampType;
15
use Symfony\Component\Form\Form;
16
use Symfony\Component\Form\Test\TypeTestCase;
17
18
/**
19
 * Test the TimestampTypeTest
20
 */
21
class TimestampTypeTest extends TypeTestCase
22
{
23
    /**
24
     * @var int
25
     */
26
    protected $time = 641073600;
27
28
    /**
29
     * Test type
30
     */
31
    public function testType(): void
32
    {
33
        /** @var Form $form */
34
        $form = $this->factory->create(TimestampType::class, new \DateTime(), ['data_class' => null]);
35
        $form->submit($this->time);
36
        $this->assertForm($form);
37
38
        $form = $this->factory->create(TimestampType::class);
39
        $form->submit($this->time);
40
        $this->assertForm($form);
41
42
        $form = $this->factory->create(TimestampType::class);
43
        $form->submit('');
44
        static::assertSame('', $form->getViewData());
45
    }
46
47
    /**
48
     * @param Form $form
49
     *
50
     * @return void
51
     */
52
    private function assertForm(Form $form): void
53
    {
54
        static::assertTrue($form->isSynchronized());
55
        static::assertSame((string) $this->time, $form->getViewData());
56
    }
57
}
58