Code Duplication    Length = 36-38 lines in 2 locations

projects/plugins/jetpack/tests/php/modules/masterbar/test-class-atomic-additional-css-manager.php 1 location

@@ 22-57 (lines=36) @@
19
/**
20
 * Class Test_Atomic_Additional_CSS_Manager
21
 */
22
class Test_Atomic_Additional_CSS_Manager extends \WP_UnitTestCase {
23
	/**
24
	 * A mock Customize manager.
25
	 *
26
	 * @var \WP_Customize_Manager
27
	 */
28
	private $wp_customize;
29
30
	/**
31
	 * Register a customizer manager.
32
	 *
33
	 * @return void
34
	 */
35
	public function setUp() {
36
		parent::setUp();
37
38
		$this->wp_customize = new \WP_Customize_Manager();
39
	}
40
41
	/**
42
	 * Check if the nudge contains the proper url and message copy.
43
	 */
44
	public function test_it_generates_proper_url_and_nudge() {
45
		$manager = new Atomic_Additional_CSS_Manager( 'foo.com' );
46
47
		$manager->register_nudge( $this->wp_customize );
48
		$this->assertEquals(
49
			'/checkout/foo.com/business',
50
			$this->wp_customize->controls()['custom_css_control']->cta_url
51
		);
52
		$this->assertEquals(
53
			'Purchase a Business Plan to<br> activate CSS customization',
54
			$this->wp_customize->controls()['custom_css_control']->nudge_copy
55
		);
56
	}
57
}
58

projects/plugins/jetpack/tests/php/modules/masterbar/test-class-wpcom-additional-css-manager.php 1 location

@@ 22-59 (lines=38) @@
19
/**
20
 * Class Test_WPCOM_Additional_Css_Manager
21
 */
22
class Test_WPCOM_Additional_Css_Manager extends \WP_UnitTestCase {
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