Completed
Push — master ( c85fa9...d312aa )
by Sam
03:06
created

UserQueryTest::getMockedUserQuery()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Jalle19\StatusManager\Test\Database;
4
5
use Jalle19\StatusManager\Database\UserQuery;
6
7
/**
8
 * Class UserQueryTest
9
 * @package   Jalle19\StatusManager\Test\Database
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 UserQueryTest extends \PHPUnit_Framework_TestCase
14
{
15
16
	/**
17
	 * There should be four filter calls for three passed names, since the DVR user is added transparently
18
	 */
19
	public function testFilterIgnoredUsers()
20
	{
21
		$mock = $this->getMockedUserQuery();
22
		$mock->expects($this->exactly(4))
23
		     ->method('filterByName');
24
25
		$ignoredUsers = [
26
			'foo',
27
			'bar',
28
			'baz',
29
		];
30
31
		$mock->filterIgnoredUsers($ignoredUsers);
32
	}
33
34
35
	/**
36
	 * When no ignored users are specified, only the DVR user should be added
37
	 */
38
	public function testFilterIgnoredUsersNone()
39
	{
40
		$mock = $this->getMockedUserQuery();
41
		$mock->expects($this->once())
42
		     ->method('filterByName');
43
44
		$mock->filterIgnoredUsers([]);
45
	}
46
47
48
	/**
49
	 * @return \PHPUnit_Framework_MockObject_MockObject|UserQuery
50
	 */
51
	private function getMockedUserQuery()
52
	{
53
		return $this->getMockBuilder(UserQuery::class)
54
		            ->setMethods(['filterByName'])
55
		            ->getMock();
56
	}
57
58
}
59