Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#14)
by Der Mundschenk
02:42
created

Node_Fix_Testcase   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 69
rs 10
c 1
b 0
f 0
wmc 7
lcom 1
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A create_textnode() 0 4 1
B assertFixResultSame() 0 22 5
1
<?php
2
/**
3
 *  This file is part of PHP-Typography.
4
 *
5
 *  Copyright 2017 Peter Putzer.
6
 *
7
 *  This program is free software; you can redistribute it and/or
8
 *  modify it under the terms of the GNU General Public License
9
 *  as published by the Free Software Foundation; either version 2
10
 *  of the License, or ( at your option ) any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program; if not, write to the Free Software
19
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
 *
21
 *  @package mundschenk-at/php-typography/tests
22
 *  @license http://www.gnu.org/licenses/gpl-2.0.html
23
 */
24
25
namespace PHP_Typography\Tests\Fixes\Node_Fixes;
26
27
use \PHP_Typography\Tests\PHP_Typography_Testcase;
28
use \PHP_Typography\Settings;
29
use \PHP_Typography\Fixes\Node_Fix;
30
31
/**
32
 * Abstract base class for \PHP_Typography\* unit tests.
33
 */
34
abstract class Node_Fix_Testcase extends PHP_Typography_Testcase {
35
36
	/**
37
	 * Settings object.
38
	 *
39
	 * @var Ssttings
40
	 */
41
	protected $s;
42
43
	/**
44
	 * Our test object.
45
	 *
46
	 * @var Node_Fix
47
	 */
48
	protected $fix;
49
50
	/**
51
	 * Sets up the fixture, for example, opens a network connection.
52
	 * This method is called before a test is executed.
53
	 */
54
	protected function setUp() { // @codingStandardsIgnoreLine
55
		$this->s = new Settings( true );
0 ignored issues
show
Documentation Bug introduced by
It seems like new \PHP_Typography\Settings(true) of type object<PHP_Typography\Settings> is incompatible with the declared type object<PHP_Typography\Te...es\Node_Fixes\Ssttings> of property $s.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
56
	}
57
58
	/**
59
	 * Create a normalilzed textnode.
60
	 *
61
	 * @param  string $value Required.
62
	 *
63
	 * @return \DOMText
64
	 */
65
	protected function create_textnode( $value ) {
66
		// returns < > & to encoded HTML characters (&lt; &gt; and &amp; respectively).
67
		return new \DOMText( htmlspecialchars( html_entity_decode( $value ), ENT_NOQUOTES, 'UTF-8', false ) );
68
	}
69
70
	/**
71
	 * Assert that the output of the fix is the same as the expected result.
72
	 *
73
	 * @param string      $input         Text node value.
74
	 * @param string      $result        Expected result.
75
	 * @param string|null $left_sibling  Optional. Left sibling node value. Default null.
76
	 * @param string|null $right_sibling Optional. Right sibling node value. Default null.
77
	 * @param string      $parent_tag    Optional. Parent tag. Default 'p'.
78
	 * @param bool        $is_title      Optional. Default false.
79
	 */
80
	protected function assertFixResultSame( $input, $result, $left_sibling = null, $right_sibling = null, $parent_tag = 'p', $is_title = false ) {
81
		$node = $this->create_textnode( $input );
82
83
		if ( ! empty( $left_sibling ) || ! empty( $right_sibling ) ) {
84
			$dom    = new \DOMDocument();
85
			$parent = new \DOMElement( $parent_tag );
86
			$dom->appendChild( $parent );
87
88
			if ( ! empty( $left_sibling ) ) {
89
				$parent->appendChild( $this->create_textnode( $left_sibling ) );
90
			}
91
92
			$parent->appendChild( $node );
93
94
			if ( ! empty( $right_sibling ) ) {
95
				$parent->appendChild( $this->create_textnode( $right_sibling ) );
96
			}
97
		}
98
99
		$this->fix->apply( $node, $this->s, $is_title );
100
		$this->assertSame( $this->clean_html( $result ), $this->clean_html( $node->data ) );
101
	}
102
}
103