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

Quote_Style_Test   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 66
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A provide_get_styled_quotes_data() 0 20 1
A test_get_styled_dashes() 0 13 2
A test_get_styled_dashes_french_guillemets() 0 9 1
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\Settings;
26
27
use \PHP_Typography\Tests\PHP_Typography_Testcase;
28
29
use \PHP_Typography\Settings\Quotes;
30
use \PHP_Typography\Settings\Quote_Style;
31
use \PHP_Typography\U;
32
33
/**
34
 * Quote_Style unit test.
35
 *
36
 * @coversDefaultClass \PHP_Typography\Settings\Quote_Style
37
 * @usesDefaultClass \PHP_Typography\Settings\Quote_Style
38
 *
39
 * @uses PHP_Typography\Settings\Simple_Quotes
40
 */
41
class Quote_Style_Test extends PHP_Typography_Testcase {
42
43
44
	/**
45
	 * Provide test data for testing get_styled_quotes.
46
	 */
47
	public function provide_get_styled_quotes_data() {
48
		return [
49
			[ Quote_Style::DOUBLE_CURLED, [ U::DOUBLE_QUOTE_OPEN, U::DOUBLE_QUOTE_CLOSE ] ],
50
			[ Quote_Style::DOUBLE_CURLED_REVERSED, [ U::DOUBLE_QUOTE_CLOSE, U::DOUBLE_QUOTE_CLOSE ] ],
51
			[ Quote_Style::DOUBLE_LOW_9, [ U::DOUBLE_LOW_9_QUOTE, U::DOUBLE_QUOTE_CLOSE ] ],
52
			[ Quote_Style::DOUBLE_LOW_9_REVERSED, [ U::DOUBLE_LOW_9_QUOTE, U::DOUBLE_QUOTE_OPEN ] ],
53
			[ Quote_Style::SINGLE_CURLED, [ U::SINGLE_QUOTE_OPEN, U::SINGLE_QUOTE_CLOSE ] ],
54
			[ Quote_Style::SINGLE_CURLED_REVERSED, [ U::SINGLE_QUOTE_CLOSE, U::SINGLE_QUOTE_CLOSE ] ],
55
			[ Quote_Style::SINGLE_LOW_9, [ U::SINGLE_LOW_9_QUOTE, U::SINGLE_QUOTE_CLOSE ] ],
56
			[ Quote_Style::SINGLE_LOW_9_REVERSED, [ U::SINGLE_LOW_9_QUOTE, U::SINGLE_QUOTE_OPEN ] ],
57
			[ Quote_Style::DOUBLE_GUILLEMETS, [ U::GUILLEMET_OPEN, U::GUILLEMET_CLOSE ] ],
58
			[ Quote_Style::DOUBLE_GUILLEMETS_REVERSED, [ U::GUILLEMET_CLOSE, U::GUILLEMET_OPEN ] ],
59
			[ Quote_Style::SINGLE_GUILLEMETS, [ U::SINGLE_ANGLE_QUOTE_OPEN, U::SINGLE_ANGLE_QUOTE_CLOSE ] ],
60
			[ Quote_Style::SINGLE_GUILLEMETS_REVERSED, [ U::SINGLE_ANGLE_QUOTE_CLOSE, U::SINGLE_ANGLE_QUOTE_OPEN ] ],
61
			[ Quote_Style::CORNER_BRACKETS, [ U::LEFT_CORNER_BRACKET, U::RIGHT_CORNER_BRACKET ] ],
62
			[ Quote_Style::WHITE_CORNER_BRACKETS, [ U::LEFT_WHITE_CORNER_BRACKET, U::RIGHT_WHITE_CORNER_BRACKET ] ],
63
			[ 'foo', null ],
64
			[ 123, null ],
65
		];
66
	}
67
68
	/**
69
	 * Test get_styled_quotes.
70
	 *
71
	 * @covers ::get_styled_quotes
72
	 *
73
	 * @dataProvider provide_get_styled_quotes_data
74
	 *
75
	 * @param  mixed      $style  Style index.
76
	 * @param  array|null $result Result array (or null).
77
	 */
78
	public function test_get_styled_dashes( $style, array $result = null ) {
79
		$s = $this->createMock( \PHP_Typography\Settings::class );
80
81
		$dashes = Quote_Style::get_styled_quotes( $style, $s );
82
83
		if ( is_array( $result ) ) {
84
			$this->assertInstanceOf( Quotes::class, $dashes );
85
			$this->assertSame( $result[0], $dashes->open() );
86
			$this->assertSame( $result[1], $dashes->close() );
87
		} else {
88
			$this->assertNull( $dashes, 'get_styled_quotes should return null for invalid indices.' );
89
		}
90
	}
91
92
	/**
93
	 * Test get_styled_quotes.
94
	 *
95
	 * @covers ::get_styled_quotes
96
	 */
97
	public function test_get_styled_dashes_french_guillemets() {
98
		$s = $this->createMock( \PHP_Typography\Settings::class );
99
100
		$dashes = Quote_Style::get_styled_quotes( Quote_Style::DOUBLE_GUILLEMETS_FRENCH, $s );
101
102
		$this->assertInstanceOf( Quotes::class, $dashes );
103
		$this->assertSame( U::GUILLEMET_OPEN, \mb_substr( $dashes->open(), 0, 1 ) );
104
		$this->assertSame( U::GUILLEMET_CLOSE, \mb_substr( $dashes->close(), -1 ) );
105
	}
106
}
107