Code Duplication    Length = 31-31 lines in 2 locations

packages/autoloader/tests/php/tests/unit/test-manifest-reader.php 2 locations

@@ 103-133 (lines=31) @@
100
	/**
101
	 * Tests that the reader only keeps the latest version when processing multiple manifests.
102
	 */
103
	public function test_read_overwrites_older_version_in_manifest() {
104
		$input_array = array();
105
106
		$this->version_selector->expects( $this->exactly( 4 ) )
107
			->method( 'is_version_update_required' )
108
			->withConsecutive(
109
				array( null, '2.0.0.0' ),
110
				array( null, '1.0.0.0' ),
111
				array( '2.0.0.0', '2.2.0.0' ),
112
				array( '1.0.0.0', '2.0.0.0' )
113
			)
114
			->willReturnOnConsecutiveCalls(
115
				true,
116
				true,
117
				true,
118
				true
119
			);
120
121
		$this->reader->read_manifests(
122
			array(
123
				TEST_DATA_PATH . '/plugins/dummy_current',
124
				TEST_DATA_PATH . '/plugins/dummy_newer',
125
			),
126
			'vendor/composer/jetpack_autoload_classmap.php',
127
			$input_array
128
		);
129
130
		$this->assertArrayHasKey( Test::class, $input_array );
131
		$this->assertEquals( '2.0.0.0', $input_array[ Test::class ]['version'] );
132
		$this->assertEquals( $input_array[ Test::class ]['path'], TEST_DATA_PATH . '/plugins/dummy_newer/includes/class-test.php' );
133
	}
134
135
	/**
136
	 * Tests that the reader ignores older versions when a newer version is already set.
@@ 138-168 (lines=31) @@
135
	/**
136
	 * Tests that the reader ignores older versions when a newer version is already set.
137
	 */
138
	public function test_read_ignores_older_version_when_newer_already_loaded() {
139
		$input_array = array();
140
141
		$this->version_selector->expects( $this->exactly( 4 ) )
142
			->method( 'is_version_update_required' )
143
			->withConsecutive(
144
				array( null, '2.2.0.0' ),
145
				array( null, '2.0.0.0' ),
146
				array( '2.2.0.0', '2.0.0.0' ),
147
				array( '2.0.0.0', '1.0.0.0' )
148
			)
149
			->willReturnOnConsecutiveCalls(
150
				true,
151
				true,
152
				false,
153
				false
154
			);
155
156
		$this->reader->read_manifests(
157
			array(
158
				TEST_DATA_PATH . '/plugins/dummy_newer',
159
				TEST_DATA_PATH . '/plugins/dummy_current',
160
			),
161
			'vendor/composer/jetpack_autoload_classmap.php',
162
			$input_array
163
		);
164
165
		$this->assertArrayHasKey( Test::class, $input_array );
166
		$this->assertEquals( '2.0.0.0', $input_array[ Test::class ]['version'] );
167
		$this->assertEquals( $input_array[ Test::class ]['path'], TEST_DATA_PATH . '/plugins/dummy_newer/includes/class-test.php' );
168
	}
169
}
170