Completed
Push — master ( 6c0735...dd8543 )
by Dennis
06:47
created

TestCase::setup_source_and_dest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 36

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 36
rs 9.344
c 0
b 0
f 0
1
<?php
2
3
namespace lloc\Msls\ContentImport;
4
5
6
use Prophecy\Argument;
7
8
class TestCase extends \Msls_UnitTestCase {
9
10
	protected function setup_source_and_dest() {
11
		$source_lang    = 'it_IT';
12
		$dest_lang      = 'de_DE';
13
		$source_blog_id = $this->factory()->blog->create();
14
		$dest_blog_id   = $this->factory()->blog->create();
15
16
		switch_to_blog( $source_blog_id );
0 ignored issues
show
introduced by
switch_to_blog is not something you should ever need to do in a VIP theme context. Instead use an API (XML-RPC, REST) to interact with other sites if needed.
Loading history...
17
		$source_post = $this->factory()->post->create_and_get();
18
		update_option( 'WPLANG', $source_lang );
19
20
		switch_to_blog( $dest_blog_id );
0 ignored issues
show
introduced by
switch_to_blog is not something you should ever need to do in a VIP theme context. Instead use an API (XML-RPC, REST) to interact with other sites if needed.
Loading history...
21
		$dest_post_id = $this->factory()->post->create();
22
		update_option( 'WPLANG', $dest_lang );
23
24
		$import_coordinates                 = new ImportCoordinates();
25
		$import_coordinates->source_blog_id = $source_blog_id;
26
		$import_coordinates->dest_blog_id   = $dest_blog_id;
27
		$import_coordinates->source_post_id = $source_post->ID;
28
		$import_coordinates->source_post    = $source_post;
29
		$import_coordinates->dest_post_id   = $dest_post_id;
30
		$import_coordinates->source_lang    = $source_lang;
31
		$import_coordinates->dest_lang      = $dest_lang;
32
33
		$logger = $this->prophesize( ImportLogger::class );
34
		$relations = $this->prophesize( Relations::class );
35
		$logger->log_information( Argument::type( 'string' ), Argument::any() )->willReturn( true );
36
		$logger->log_success( Argument::type( 'string' ), Argument::any() )->willReturn( true );
37
		$logger->log_error( Argument::type( 'string' ), Argument::any() )->willReturn( true );
38
		$relations->should_create( Argument::any(), Argument::type( 'string' ), Argument::type( 'string' ) )->willReturn( true );
39
40
		$data      = $this->factory()->post->create_and_get();
41
42
		restore_current_blog();
43
44
		return array( $import_coordinates, $logger, $relations, (array) $data );
45
	}
46
}