DaterTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 81
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 9 1
A tearDown() 0 4 1
A testInit() 0 19 1
A testGetFormat() 0 19 1
1
<?php
2
namespace Redaxscript\Tests;
3
4
use Redaxscript\Dater;
5
6
/**
7
 * DaterTest
8
 *
9
 * @since 4.0.0
10
 *
11
 * @package Redaxscript
12
 * @category Tests
13
 * @author Henry Ruhs
14
 *
15
 * @covers Redaxscript\Dater
16
 */
17
18
class DaterTest extends TestCaseAbstract
19
{
20
	/**
21
	 * setUp
22
	 *
23
	 * @since 4.0.0
24
	 */
25
26
	public function setUp() : void
27
	{
28
		parent::setUp();
29
		$optionArray = $this->getOptionArray();
30
		$installer = $this->installerFactory();
31
		$installer->init();
32
		$installer->rawCreate();
33
		$installer->insertSettings($optionArray);
34
	}
35
36
	/**
37
	 * tearDown
38
	 *
39
	 * @since 4.0.0
40
	 */
41
42
	public function tearDown() : void
43
	{
44
		$this->dropDatabase();
45
	}
46
47
	/**
48
	 * testInit
49
	 *
50
	 * @since 4.0.0
51
	 */
52
53
	public function testInit() : void
54
	{
55
		/* setup */
56
57
		$dater = new Dater();
58
		$dater->init();
59
60
		/* actual */
61
62
		$actualDateTime = $dater->getDateTime();
63
		$actualTimeZone = $dater->getTimeZone();
64
		$actualTimeStamp = $dater->getDateTime()->getTimestamp();
65
66
		/* compare */
67
68
		$this->assertInstanceOf('DateTime', $actualDateTime);
69
		$this->assertInstanceOf('DateTimeZone', $actualTimeZone);
70
		$this->assertNotEquals(0, $actualTimeStamp);
71
	}
72
73
	/**
74
	 * testGetFormat
75
	 *
76
	 * @since 4.0.0
77
	 */
78
79
	public function testGetFormat() : void
80
	{
81
		/* setup */
82
83
		$dater = new Dater();
84
		$dater->init(1483261800);
85
86
		/* actual */
87
88
		$actualTime = $dater->formatTime();
89
		$actualDate = $dater->formatDate();
90
		$actualField = $dater->formatField();
91
92
		/* compare */
93
94
		$this->assertEquals('10:10', $actualTime);
95
		$this->assertEquals('01.01.2017', $actualDate);
96
		$this->assertEquals('2017-01-01T10:10', $actualField);
97
	}
98
}
99