Issues (28)

tests/cli/Database/UserQueryTest.php (3 issues)

1
<?php
2
3
namespace Jalle19\StatusManager\Test\Database;
4
5
use Jalle19\StatusManager\Database\UserQuery;
6
use PHPUnit\Framework\TestCase;
7
8
/**
9
 * Class UserQueryTest
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 UserQueryTest extends TestCase
15
{
16
17
	/**
18
	 * There should be four filter calls for three passed names, since the DVR user is added transparently
19
	 */
20
	public function testFilterIgnoredUsers()
21
	{
22
		$mock = $this->getMockedUserQuery();
23
		$mock->expects($this->exactly(4))
0 ignored issues
show
The method expects() does not exist on Jalle19\StatusManager\Database\UserQuery. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
		$mock->/** @scrutinizer ignore-call */ 
24
         expects($this->exactly(4))
Loading history...
24
		     ->method('filterByName');
25
26
		$ignoredUsers = [
27
			'foo',
28
			'bar',
29
			'baz',
30
		];
31
32
		$mock->filterIgnoredUsers($ignoredUsers);
33
	}
34
35
36
	/**
37
	 * When no ignored users are specified, only the DVR user should be added
38
	 */
39
	public function testFilterIgnoredUsersNone()
40
	{
41
		$mock = $this->getMockedUserQuery();
42
		$mock->expects($this->once())
43
		     ->method('filterByName');
44
45
		$mock->filterIgnoredUsers([]);
46
	}
47
48
49
	/**
50
	 * @return \PHPUnit_Framework_MockObject_MockObject|UserQuery
51
	 */
52
	private function getMockedUserQuery()
53
	{
54
		return $this->getMockBuilder(UserQuery::class)
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getMockBui...terByName'))->getMock() returns the type PHPUnit\Framework\MockObject\MockObject which is incompatible with the documented return type Jalle19\StatusManager\Da...k_MockObject_MockObject.
Loading history...
Deprecated Code introduced by
The function PHPUnit\Framework\MockOb...ckBuilder::setMethods() has been deprecated: https://github.com/sebastianbergmann/phpunit/pull/3687 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

54
		return /** @scrutinizer ignore-deprecated */ $this->getMockBuilder(UserQuery::class)

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
55
		            ->setMethods(['filterByName'])
56
		            ->getMock();
57
	}
58
59
}
60