testGetMessageLog_withLogGivenToConstructor()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 13
rs 9.9666
1
<?php
2
/**
3
 * This file is part of the MediaWiki extension Lingo.
4
 *
5
 * @copyright 2011 - 2017, Stephan Gambke
6
 * @license GPL-2.0-or-later
7
 *
8
 * The Lingo extension is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by the Free
10
 * Software Foundation; either version 2 of the License, or (at your option) any
11
 * later version.
12
 *
13
 * The Lingo extension is distributed in the hope that it will be useful, but
14
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16
 * details.
17
 *
18
 * You should have received a copy of the GNU General Public License along
19
 * with this program. If not, see <http://www.gnu.org/licenses/>.
20
 *
21
 * @author Stephan Gambke
22
 * @since 2.0
23
 * @file
24
 * @ingroup Lingo
25
 */
26
27
namespace Lingo\Tests\Unit;
28
29
/**
30
 * @group extensions-lingo
31
 * @group extensions-lingo-unit
32
 * @group mediawiki-databaseless
33
 *
34
 * @coversDefaultClass \Lingo\Backend
35
 * @covers ::<private>
36
 * @covers ::<protected>
37
 *
38
 * @ingroup Lingo
39
 * @ingroup Test
40
 */
41
class BackendTest extends \PHPUnit\Framework\TestCase {
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
42
43
	/**
44
	 * @covers ::__construct
45
	 * @covers ::getMessageLog
46
	 */
47
	public function testGetMessageLog_withLogGivenToConstructor() {
48
		$log = $this->getMockBuilder( '\Lingo\MessageLog' )
49
			->getMock();
50
51
		$stub = $this->getMockBuilder( '\Lingo\Backend' )
52
			->disableOriginalConstructor()
53
			->getMockForAbstractClass();
54
55
		$reflected = new \ReflectionClass( '\Lingo\Backend' );
56
		$constructor = $reflected->getConstructor();
57
		$constructor->invokeArgs( $stub, [ &$log ] );
58
59
		$this->assertEquals( $log, $stub->getMessageLog() );
60
	}
61
62
	/**
63
	 * @covers ::__construct
64
	 * @covers ::getMessageLog
65
	 */
66
	public function testGetMessageLog_withoutLogGivenToConstructor() {
67
		$stub = $this->getMockBuilder( '\Lingo\Backend' )
68
			->disableOriginalConstructor()
69
			->getMockForAbstractClass();
70
71
		$reflected = new \ReflectionClass( '\Lingo\Backend' );
72
		$constructor = $reflected->getConstructor();
73
		$constructor->invoke( $stub );
74
75
		$this->assertInstanceOf( '\Lingo\MessageLog', $stub->getMessageLog() );
76
	}
77
78
	/**
79
	 * @covers ::useCache
80
	 */
81
	public function testUseCache() {
82
		$stub = $this->getMockForAbstractClass( '\Lingo\Backend' );
83
84
		$this->assertFalse( $stub->useCache() );
85
	}
86
87
	/**
88
	 * @covers ::setLingoParser
89
	 * @covers ::getLingoParser
90
	 */
91
	public function testSetGetLingoParser() {
92
		$stub = $this->getMockForAbstractClass( '\Lingo\Backend' );
93
		$parserMock = $this->getMockBuilder( '\Lingo\LingoParser' )
94
			->getMock();
95
96
		$stub->setLingoParser( $parserMock );
97
		$this->assertEquals( $parserMock, $stub->getLingoParser() );
98
	}
99
100
	/**
101
	 * @covers ::setLingoParser
102
	 * @covers ::getLingoParser
103
	 */
104
	public function testGetLingoParser_withoutParserGiven() {
105
		$stub = $this->getMockForAbstractClass( '\Lingo\Backend' );
106
		$this->assertInstanceOf( '\Lingo\LingoParser', $stub->getLingoParser() );
107
	}
108
}
109