Completed
Push — refonte ( 64e01a...7173e3 )
by Arnaud
03:31
created

DateTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testRender() 0 13 1
A testRenderInvalidValue() 0 8 1
1
<?php
2
3
namespace LAG\AdminBundle\Tests\AdminBundle\Field;
4
5
use DateTime;
6
use LAG\AdminBundle\Field\Field\Date;
7
use LAG\AdminBundle\Tests\AdminTestBase;
8
9
class DateTest extends AdminTestBase
10
{
11
    public function testRender()
12
    {
13
        $linkField = new Date('my-field');
14
        
15
        $this->setPrivateProperty($linkField, 'options', [
16
            'format' => 'd/m/Y',
17
        ]);
18
    
19
        $now = new DateTime();
20
        $content = $linkField->render($now);
21
    
22
        $this->assertEquals($now->format('d/m/Y'), $content);
23
    }
24
    
25
    public function testRenderInvalidValue()
26
    {
27
        $linkField = new Date('my-field');
28
    
29
        $this->assertExceptionRaised(\Exception::class, function () use ($linkField) {
30
            $linkField->render('2017-10-05');
31
        });
32
    }
33
}
34