Code Duplication    Length = 17-19 lines in 4 locations

projects/packages/jitm/tests/php/test_pre_connection_jitm.php 4 locations

@@ 69-86 (lines=18) @@
66
	/**
67
	 * The pre-connection JITMs are disabled by default by the `jetpack_pre_connection_prompt_helpers` filter's default value.
68
	 */
69
	public function test_get_messages_prompt_helpers_default() {
70
		Filters\expectApplied( 'jetpack_pre_connection_prompt_helpers' )
71
			->once()
72
			->with( false );
73
74
		Functions\expect( 'current_user_can' )
75
			->atMost()
76
			->once()
77
			->andReturn( true );
78
79
		Filters\expectApplied( 'jetpack_pre_connection_jitms' )
80
			->atMost()
81
			->once()
82
			->with( array() )
83
			->andReturn( $this->test_jitms );
84
85
		$this->assertEmpty( $this->jitm_instance->get_messages( '/wp:plugins:admin_notices/', '', false ) );
86
	}
87
88
	/**
89
	 * The pre-connection JITMs are disabled when the current user does not have the 'install_plugins' capability.
@@ 91-107 (lines=17) @@
88
	/**
89
	 * The pre-connection JITMs are disabled when the current user does not have the 'install_plugins' capability.
90
	 */
91
	public function test_get_messages_user_cannot_install_plugins() {
92
		Filters\expectApplied( 'jetpack_pre_connection_prompt_helpers' )
93
			->atMost()
94
			->once()
95
			->with( false )
96
			->andReturns( true );
97
98
		Functions\expect( 'current_user_can' )
99
			->once()
100
			->andReturn( false );
101
102
		Filters\expectApplied( 'jetpack_pre_connection_jitms' )
103
			->atMost()
104
			->once()
105
			->with( array() )
106
			->andReturn( $this->test_jitms );
107
108
		$this->assertEmpty( $this->jitm_instance->get_messages( '/wp:plugins:admin_notices/', '', false ) );
109
	}
110
@@ 115-132 (lines=18) @@
112
	 * The pre-connection JITMs are empty by default. The default value of the 'jetpack_pre_connection_jitms' filter is 
113
	 * an empty array.
114
	 */
115
	public function test_get_messages_jitms_filter_default() {
116
		Filters\expectApplied( 'jetpack_pre_connection_prompt_helpers' )
117
			->atMost()
118
			->once()
119
			->with( false )
120
			->andReturns( true );
121
122
		Functions\expect( 'current_user_can' )
123
			->atMost()
124
			->once()
125
			->andReturn( true );
126
127
		Filters\expectApplied( 'jetpack_pre_connection_jitms' )
128
			->once()
129
			->with( array() );
130
131
		$this->assertEmpty( $this->jitm_instance->get_messages( '/wp:plugins:admin_notices/', '', false ) );
132
	}
133
134
	/**
135
	 * The Pre_Connection_JITM::get_messages method returns an empty array when the the 'jetpack_pre_connection_jitms' filter
@@ 138-156 (lines=19) @@
135
	 * The Pre_Connection_JITM::get_messages method returns an empty array when the the 'jetpack_pre_connection_jitms' filter
136
	 * returns anything other than an array.
137
	 */
138
	public function test_get_messages_filter_returns_string() {
139
		Filters\expectApplied( 'jetpack_pre_connection_prompt_helpers' )
140
			->atMost()
141
			->once()
142
			->with( false )
143
			->andReturns( true );
144
145
		Functions\expect( 'current_user_can' )
146
			->atMost()
147
			->once()
148
			->andReturn( true );
149
150
		Filters\expectApplied( 'jetpack_pre_connection_jitms' )
151
			->once()
152
			->with( array() )
153
			->andReturn( 'a string intead of an array' );
154
155
		$this->assertEmpty( $this->jitm_instance->get_messages( '/wp:plugins:admin_notices/', '', false ) );
156
	}
157
158
	/**
159
	 * The pre-connection JITMs are added using the `jetpack_pre_connection_jitms` filter.