DuplicatingTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A should_duplicate_post_fields_from_the_source_post_to_the_destination() 0 22 3
1
<?php
2
3
namespace lloc\Msls\ContentImport\Importers\PostFields;
4
5
6
use lloc\Msls\ContentImport\TestCase;
7
8
class DuplicatingTest extends TestCase {
9
	/**
10
	 * It should duplicate post fields from the source post to the destination
11
	 *
12
	 * @test
13
	 */
14
	public function should_duplicate_post_fields_from_the_source_post_to_the_destination() {
15
		list( $import_coordinates, $logger, $relations, $dest_post_data ) = $this->setup_source_and_dest();
16
17
		restore_current_blog();
18
19
		$obj     = new Duplicating( $import_coordinates, $logger->reveal(), $relations->reveal() );
20
21
		$source_post_data     = (array) $import_coordinates->source_post;
22
		$imported_fields      = array_flip( $obj->filter_fields() );
23
		$fields_to_import     = array_intersect_key( $source_post_data, $imported_fields );
24
		$fields_not_to_import = array_diff_key( $dest_post_data, $imported_fields );
25
26
		$mutated = $obj->import( $dest_post_data );
27
28
		foreach ( $fields_to_import as $field => $value ) {
29
			$this->assertEquals( $value, $mutated[ $field ] );
30
		}
31
32
		foreach ( $fields_not_to_import as $field => $value ) {
33
			$this->assertEquals( $dest_post_data[ $field ], $mutated[ $field ] );
34
		}
35
	}
36
}
37