Completed
Push — master ( 4ceab2...5384e5 )
by Sam
03:45
created

SubscriptionQueryTest::testFilterByTimeFrame()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 1
eloc 7
nc 1
nop 2
1
<?php
2
3
namespace Jalle19\StatusManager\Test\Database;
4
5
use Jalle19\StatusManager\Database\SubscriptionQuery;
6
use Jalle19\StatusManager\TimeFrame;
7
8
/**
9
 * Class SubscriptionQueryTest
10
 * @package   Jalle19\StatusManager\Test\Database
11
 * @copyright Copyright &copy; Sam Stenvall 2016-
12
 * @license   https://www.gnu.org/licenses/gpl.html The GNU General Public License v2.0
13
 */
14
class SubscriptionQueryTest extends \PHPUnit_Framework_TestCase
15
{
16
17
	/**
18
	 * Checks that filtering is applied appropriately depending on the specified time frame
19
	 * @dataProvider provider
20
	 */
21
	public function testFilterByTimeFrame($expects, $timeFrame)
22
	{
23
		/* @var \PHPUnit_Framework_MockObject_MockObject|SubscriptionQuery $mock */
24
		$mock = $this->getMockBuilder(SubscriptionQuery::class)
25
		             ->setMethods(['filterByStopped'])
26
		             ->getMock();
27
28
		$mock->expects($expects)
29
		     ->method('filterByStopped');
30
31
		$mock->filterByTimeFrame(new TimeFrame($timeFrame));
32
	}
33
34
35
	/**
36
	 * @return array
37
	 */
38
	public function provider()
39
	{
40
		return [
41
			[$this->never(), TimeFrame::TIME_FRAME_ALL_TIME],
42
			[$this->once(), TimeFrame::TIME_FRAME_LAST_MONTH],
43
			[$this->once(), TimeFrame::TIME_FRAME_LAST_WEEK],
44
			[$this->once(), TimeFrame::TIME_FRAME_LAST_DAY],
45
		];
46
	}
47
48
}
49