Completed
Push — update/add-csstidy-config-sett... ( 30eb4b...0a5859 )
by
unknown
19:15 queued 09:40
created

Test_WPCOM_Additional_Css_Manager::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 5
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 5
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Test_WPCOM_Additional_Css_Manager file.
4
 * Test WPCOM_Additional_CSS_Manager.
5
 *
6
 * @package Jetpack
7
 */
8
9
namespace Automattic\Jetpack\Dashboard_Customizations;
10
11
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
12
require_once ABSPATH . WPINC . '/class-wp-customize-control.php';
13
require_once ABSPATH . WPINC . '/class-wp-customize-section.php';
14
15
require_jetpack_file( 'modules/masterbar/nudges/additional-css/class-wpcom-additional-css-manager.php' );
16
require_jetpack_file( 'modules/masterbar/nudges/additional-css/class-css-nudge-customize-control.php' );
17
require_jetpack_file( 'modules/masterbar/nudges/additional-css/class-css-customizer-nudge.php' );
18
19
/**
20
 * Class Test_WPCOM_Additional_Css_Manager
21
 */
22 View Code Duplication
class Test_WPCOM_Additional_Css_Manager extends \WP_UnitTestCase {
0 ignored issues
show
Duplication introduced by
This class 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...
23
24
	/**
25
	 * A mock Customize manager.
26
	 *
27
	 * @var \WP_Customize_Manager
28
	 */
29
	private $wp_customize;
30
31
	/**
32
	 * Register a customizer manager.
33
	 *
34
	 * @return void
35
	 */
36
	public function setUp() {
37
		parent::setUp();
38
39
		$this->wp_customize = new \WP_Customize_Manager();
40
	}
41
42
	/**
43
	 * Check if the manager constructs the proper url and copy message.
44
	 */
45
	public function test_it_generates_proper_url_and_nudge() {
46
		$manager = new WPCOM_Additional_CSS_Manager( 'foo.com' );
47
48
		$manager->register_nudge( $this->wp_customize );
49
		$this->assertEquals(
50
			'/checkout/foo.com/premium',
51
			$this->wp_customize->controls()['jetpack_custom_css_control']->cta_url
52
		);
53
		$this->assertEquals(
54
			'Purchase a Premium Plan to<br> activate CSS customization',
55
			$this->wp_customize->controls()['jetpack_custom_css_control']->nudge_copy
56
		);
57
58
	}
59
}
60