Completed
Push — master ( fc24bd...39caf5 )
by Sam
03:18
created

TimeFrameTest::timestampProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace Jalle19\StatusManager\Test;
4
5
use Jalle19\StatusManager\TimeFrame;
6
7
/**
8
 * Class TimeFrameTest
9
 * @package   Jalle19\StatusManager\Test
10
 * @copyright Copyright &copy; Sam Stenvall 2016-
11
 * @license   https://www.gnu.org/licenses/gpl.html The GNU General Public License v2.0
12
 */
13
class TimeFrameTest extends \PHPUnit_Framework_TestCase
14
{
15
16
	/**
17
	 * @expectedException \InvalidArgumentException
18
	 */
19
	public function testConstructor()
20
	{
21
		new TimeFrame('invalid');
22
	}
23
24
25
	/**
26
	 * A data provider can't be used since it's evaluated long before the test method is run, scewing the timestamps
27
	 */
28
	public function testGetTimestamp()
29
	{
30
		foreach ($this->timestampProvider() as $data)
31
		{
32
			$timeFrame = new TimeFrame($data[0]);
33
			$this->assertEquals($data[1], $timeFrame->getTimestamp());
34
		}
35
	}
36
37
38
	/**
39
	 * @return array
40
	 */
41
	public function timestampProvider()
42
	{
43
		return [
44
			[TimeFrame::TIME_FRAME_ALL_TIME, (new \DateTime())->getTimestamp()],
45
			[TimeFrame::TIME_FRAME_LAST_MONTH, (new \DateTime('-1 month'))->getTimestamp()],
46
			[TimeFrame::TIME_FRAME_LAST_WEEK, (new \DateTime('-1 week'))->getTimestamp()],
47
			[TimeFrame::TIME_FRAME_LAST_DAY, (new \DateTime('-1 day'))->getTimestamp()],
48
		];
49
	}
50
51
}
52