-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
110 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
tests/phpunit/ContentImport/Importers/PostFields/TestDuplicating.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace lloc\MslsTests\ContentImport\Importers\PostFields; | ||
|
||
use Brain\Monkey\Functions; | ||
use lloc\Msls\ContentImport\ImportCoordinates; | ||
use lloc\Msls\ContentImport\Importers\PostFields\Duplicating; | ||
use lloc\MslsTests\MslsUnitTestCase; | ||
|
||
class TestDuplicating extends MslsUnitTestCase { | ||
|
||
public function testImport(): void { | ||
Functions\expect( 'wp_insert_post' )->once(); | ||
|
||
$post = \Mockery::mock( \WP_Post::class ); | ||
$post->post_excerpt = 'excerpt'; | ||
$post->post_title = 'title'; | ||
$post->post_content = 'content'; | ||
$post->post_content_filtered = 'content_filtered'; | ||
|
||
$coordinates = \Mockery::mock( ImportCoordinates::class ); | ||
$coordinates->source_post = $post; | ||
|
||
$result = array( | ||
'post_type' => 'post', | ||
'post_content' => 'content', | ||
'post_content_filtered' => 'content_filtered', | ||
'post_title' => 'title', | ||
'post_excerpt' => 'excerpt', | ||
); | ||
|
||
$this->assertEquals( $result, ( new Duplicating( $coordinates ) )->import( array() ) ); | ||
} | ||
|
||
public function testFilterFields(): void { | ||
$coordinates = \Mockery::mock( ImportCoordinates::class ); | ||
|
||
$test = new Duplicating( $coordinates ); | ||
|
||
$result = array( | ||
'post_content', | ||
'post_content_filtered', | ||
'post_title', | ||
'post_excerpt', | ||
); | ||
|
||
$this->assertEquals( $result, $test->filter_fields() ); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
tests/phpunit/ContentImport/Importers/TestImportersBaseFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace lloc\MslsTests\ContentImport\Importers; | ||
|
||
use lloc\Msls\ContentImport\ImportCoordinates; | ||
use lloc\Msls\ContentImport\Importers\ImportersBaseFactory; | ||
use lloc\MslsTests\MslsUnitTestCase; | ||
use Mockery\Mock; | ||
|
||
class TestImportersBaseFactory extends MslsUnitTestCase { | ||
|
||
public function testMake(): void { | ||
$coordinates = \Mockery::mock( ImportCoordinates::class ); | ||
$coordinates->shouldReceive( 'get_importer_for' )->andReturn( 'post-fields' ); | ||
|
||
$test = \Mockery::mock( ImportersBaseFactory::class )->makePartial(); | ||
|
||
$this->expectException( \RuntimeException::class ); | ||
|
||
$test->make( $coordinates ); | ||
} | ||
|
||
public function testDetails(): void { | ||
$test = \Mockery::mock( ImportersBaseFactory::class )->makePartial(); | ||
|
||
$this->assertNotEmpty( $test->details() ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace lloc\MslsTests\ContentImport\Importers; | ||
|
||
use lloc\Msls\ContentImport\ImportCoordinates; | ||
use lloc\Msls\ContentImport\Importers\Map; | ||
use lloc\MslsTests\MslsUnitTestCase; | ||
|
||
class TestMap extends MslsUnitTestCase { | ||
|
||
public function testMake(): void { | ||
$coordinates = \Mockery::mock( ImportCoordinates::class ); | ||
$coordinates->shouldReceive( 'get_importer_for' )->andReturn( 'post-fields' ); | ||
|
||
$result = ( new Map() )->make( $coordinates ); | ||
|
||
$this->assertNotEmpty( $result ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters