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

Dewidow_Fix_Test::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 *  This file is part of PHP-Typography.
4
 *
5
 *  Copyright 2015-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\Fixes\Node_Fixes\Dewidow_Fix;
28
use \PHP_Typography\Settings;
29
30
/**
31
 * Dewidow_Fix unit test.
32
 *
33
 * @coversDefaultClass \PHP_Typography\Fixes\Node_Fixes\Dewidow_Fix
34
 * @usesDefaultClass \PHP_Typography\Fixes\Node_Fixes\Dewidow_Fix
35
 *
36
 * @uses ::__construct
37
 * @uses PHP_Typography\Arrays
38
 * @uses PHP_Typography\DOM
39
 * @uses PHP_Typography\Settings
40
 * @uses PHP_Typography\Settings\Dash_Style
41
 * @uses PHP_Typography\Settings\Quote_Style
42
 * @uses PHP_Typography\Settings\Simple_Dashes
43
 * @uses PHP_Typography\Settings\Simple_Quotes
44
 * @uses PHP_Typography\Strings
45
 */
46
class Dewidow_Fix_Test extends Node_Fix_Testcase {
47
	/**
48
	 * Sets up the fixture, for example, opens a network connection.
49
	 * This method is called before a test is executed.
50
	 */
51
	protected function setUp() { // @codingStandardsIgnoreLine
52
		parent::setUp();
53
54
		$this->fix = new Dewidow_Fix();
55
	}
56
57
	/**
58
	 * Provide data for testing dewidowing.
59
	 *
60
	 * @return array
61
	 */
62
	public function provide_dewidow_data() {
63
		return [
64
			[ 'bla foo b', 'bla foo&nbsp;b', 3, 2 ],
65
			[ 'bla foo&thinsp;b', 'bla foo&thinsp;b', 3, 2 ], // don't replace thin space...
66
			[ 'bla foo&#8202;b', 'bla foo&#8202;b', 3, 2 ],   // ... or hair space.
67
			[ 'bla foo bar', 'bla foo bar', 2, 2 ],
68
			[ 'bla foo bär...', 'bla foo&nbsp;b&auml;r...', 3, 3 ],
69
			[ 'bla foo bär&hellip;!', 'bla foo&nbsp;b&auml;r&hellip;!', 3, 3 ],
70
			[ 'bla foo bär&shy;!', 'bla foo&nbsp;b&auml;r!', 3, 3 ],
71
			[ 'bla foo b&shy;är!', 'bla foo&nbsp;b&auml;r!', 3, 3 ],
72
			[ 'bla foo b&#8203;är!', 'bla foo&nbsp;b&auml;r!', 3, 3 ],
73
			[ 'bla foo&nbsp;bär...', 'bla foo&nbsp;b&auml;r...', 3, 3 ],
74
			[ 'bla föö&#8203;bar s', 'bla f&ouml;&ouml;&#8203;bar&nbsp;s', 3, 2 ],
75
			[ 'bla foo&#8203;bar s', 'bla foo&#8203;bar s', 2, 2 ],
76
			[ 'bla foo&shy;bar', 'bla foo&shy;bar', 3, 3 ], // &shy; not matched.
77
			[ 'bla foo&shy;bar bar', 'bla foo&shy;bar&nbsp;bar', 3, 3 ], // &shy; not matched, but syllable after is.
78
			[ 'bla foo&#8203;bar bar', 'bla foo&#8203;bar&nbsp;bar', 3, 3 ],
79
			[ 'bla foo&nbsp;bar bar', 'bla foo&nbsp;bar bar', 3, 3 ], // widow not replaced because the &nbsp; would pull too many letters from previous.
80
		];
81
	}
82
83
	/**
84
	 * Test apply.
85
	 *
86
	 * @covers ::apply
87
	 *
88
	 * @dataProvider provide_dewidow_data
89
	 *
90
	 * @param string $html       HTML input.
91
	 * @param string $result     Expected result.
92
	 * @param int    $max_pull   Maximum number of pulled characters.
93
	 * @param int    $max_length Maximum word length for dewidowing.
94
	 */
95 View Code Duplication
	public function test_apply( $html, $result, $max_pull, $max_length ) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
96
		$this->s->set_dewidow( true );
97
		$this->s->set_max_dewidow_pull( $max_pull );
98
		$this->s->set_max_dewidow_length( $max_length );
99
100
		$this->assertFixResultSame( $html, $result );
101
	}
102
103
	/**
104
	 * Test dewidow.
105
	 *
106
	 * @covers ::apply
107
	 *
108
	 * @dataProvider provide_dewidow_data
109
	 *
110
	 * @param string $html       HTML input.
111
	 * @param string $result     Expected result.
112
	 * @param int    $max_pull   Maximum number of pulled characters.
113
	 * @param int    $max_length Maximum word length for dewidowing.
114
	 */
115 View Code Duplication
	public function test_apply_off( $html, $result, $max_pull, $max_length ) {
0 ignored issues
show
Unused Code introduced by
The parameter $result is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
116
		$this->s->set_dewidow( false );
117
		$this->s->set_max_dewidow_pull( $max_pull );
118
		$this->s->set_max_dewidow_length( $max_length );
119
120
		$this->assertFixResultSame( $html, $html );
121
	}
122
}
123