Skip to content

Commit 8a00281

Browse files
committed
Tests added
1 parent 4b14517 commit 8a00281

File tree

2 files changed

+49
-3
lines changed

2 files changed

+49
-3
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace lloc\MslsTests\ContentImport;
4+
5+
use lloc\Msls\ContentImport\ImportCoordinates;
6+
use lloc\MslsTests\MslsUnitTestCase;
7+
use Brain\Monkey\Functions;
8+
9+
class TestImportCoordinates extends MslsUnitTestCase {
10+
11+
12+
public function setUp(): void {
13+
parent::setUp();
14+
15+
$this->test = new ImportCoordinates();
16+
17+
$this->test->source_blog_id = 1;
18+
$this->test->source_post_id = 42;
19+
$this->test->dest_blog_id = 2;
20+
$this->test->dest_post_id = 13;
21+
$this->test->source_post = \Mockery::mock( \WP_Post::class );
22+
$this->test->source_lang = 'de_DE';
23+
$this->test->dest_lang = 'it_IT';
24+
}
25+
26+
public function provider_validate(): array {
27+
$post = \Mockery::mock( \WP_Post::class );
28+
return array(
29+
array( null, null, null, null, null, false ),
30+
array( $post, null, null, null, null, false ),
31+
array( $post, $post, null, null, null, false ),
32+
array( $post, $post, $post, null, null, false ),
33+
array( $post, $post, $post, 'de_DE', null, false ),
34+
array( $post, $post, $post, 'de_DE', 'it_IT', true ),
35+
);
36+
}
37+
38+
/**
39+
* @dataProvider provider_validate
40+
*/
41+
public function test_validate( $post_a, $post_b, $source_post, $lang_a, $lang_b, $expected ): void {
42+
Functions\expect( 'get_blog_post' )->andReturn( $post_a, $post_b );
43+
Functions\expect( 'get_blog_option' )->andReturn( $lang_a, $lang_b );
44+
45+
$this->test->source_post = $source_post;
46+
47+
$this->assertEquals( $expected, $this->test->validate() );
48+
}
49+
}

tests/phpunit/ContentImport/TestImportLogger.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44

55
use lloc\Msls\ContentImport\ImportCoordinates;
66
use lloc\Msls\ContentImport\ImportLogger;
7-
use lloc\Msls\ContentImport\Service;
8-
use lloc\Msls\MslsOptions;
97
use lloc\MslsTests\MslsUnitTestCase;
10-
use Brain\Monkey\Functions;
118

129
class TestImportLogger extends MslsUnitTestCase {
1310

0 commit comments

Comments
 (0)