Code Duplication    Length = 12-13 lines in 3 locations

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

@@ 69-81 (lines=13) @@
66
	/**
67
	 * The pre-connection JITMs are disabled when the current user does not have the 'install_plugins' capability.
68
	 */
69
	public function test_get_messages_user_cannot_install_plugins() {
70
		Functions\expect( 'current_user_can' )
71
			->once()
72
			->andReturn( false );
73
74
		Filters\expectApplied( 'jetpack_pre_connection_jitms' )
75
			->atMost()
76
			->once()
77
			->with( array() )
78
			->andReturn( $this->test_jitms );
79
80
		$this->assertEmpty( $this->jitm_instance->get_messages( '/wp:plugins:admin_notices/', '', false ) );
81
	}
82
83
	/**
84
	 * The pre-connection JITMs are empty by default. The default value of the 'jetpack_pre_connection_jitms' filter is
@@ 87-98 (lines=12) @@
84
	 * The pre-connection JITMs are empty by default. The default value of the 'jetpack_pre_connection_jitms' filter is
85
	 * an empty array.
86
	 */
87
	public function test_get_messages_jitms_filter_default() {
88
		Functions\expect( 'current_user_can' )
89
			->atMost()
90
			->once()
91
			->andReturn( true );
92
93
		Filters\expectApplied( 'jetpack_pre_connection_jitms' )
94
			->once()
95
			->with( array() );
96
97
		$this->assertEmpty( $this->jitm_instance->get_messages( '/wp:plugins:admin_notices/', '', false ) );
98
	}
99
100
	/**
101
	 * The Pre_Connection_JITM::get_messages method returns an empty array when the the 'jetpack_pre_connection_jitms' filter
@@ 104-116 (lines=13) @@
101
	 * The Pre_Connection_JITM::get_messages method returns an empty array when the the 'jetpack_pre_connection_jitms' filter
102
	 * returns anything other than an array.
103
	 */
104
	public function test_get_messages_filter_returns_string() {
105
		Functions\expect( 'current_user_can' )
106
			->atMost()
107
			->once()
108
			->andReturn( true );
109
110
		Filters\expectApplied( 'jetpack_pre_connection_jitms' )
111
			->once()
112
			->with( array() )
113
			->andReturn( 'a string intead of an array' );
114
115
		$this->assertEmpty( $this->jitm_instance->get_messages( '/wp:plugins:admin_notices/', '', false ) );
116
	}
117
118
	/**
119
	 * The pre-connection JITMs are added using the `jetpack_pre_connection_jitms` filter.