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 ); |
|
|
|
|
17
|
|
|
$source_post = $this->factory()->post->create_and_get(); |
18
|
|
|
update_option( 'WPLANG', $source_lang ); |
19
|
|
|
|
20
|
|
|
switch_to_blog( $dest_blog_id ); |
|
|
|
|
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
|
|
|
} |