File tree Expand file tree Collapse file tree 4 files changed +79
-2
lines changed
tests/phpunit/ContentImport Expand file tree Collapse file tree 4 files changed +79
-2
lines changed Original file line number Diff line number Diff line change 18
18
<const name =" MSLS_PLUGIN_PATH" value =" multisite-language-switcher/MultisiteLanguageSwitcher.php" />
19
19
<const name =" MSLS_PLUGIN__FILE__" value =" /var/www/html/wp-content/plugins/multisite-language-switcher/MultisiteLanguageSwitcher.php" />
20
20
<const name =" WP_DEBUG" value =" true" />
21
+ <const name =" HOUR_IN_SECONDS" value =" 3600" />
21
22
</php >
22
23
<testsuite name =" Internal tests" >
23
24
<directory prefix =" Test" suffix =" .php" >tests/phpunit</directory >
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace lloc \MslsTests \ContentImport \Importers \Attachments ;
4
+
5
+ use Brain \Monkey \Functions ;
6
+ use lloc \Msls \ContentImport \ImportCoordinates ;
7
+ use lloc \Msls \ContentImport \Importers \Attachments \Linking ;
8
+ use lloc \MslsTests \MslsUnitTestCase ;
9
+
10
+ class TestLinking extends MslsUnitTestCase {
11
+
12
+ public function testImport (): void {
13
+ $ coordinates = \Mockery::mock ( ImportCoordinates::class );
14
+
15
+ $ this ->assertEquals ( array (), ( new Linking ( $ coordinates ) )->import ( array () ) );
16
+ }
17
+
18
+ public function testInfo (): void {
19
+ $ object = (object ) array (
20
+ 'slug ' => 'linking ' ,
21
+ 'name ' => 'Linking ' ,
22
+ 'description ' => 'Links the media attachments from the source post to the destination post; media attachments are not duplicated. ' ,
23
+ );
24
+ $ this ->assertEquals ( $ object , Linking::info () );
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace lloc \MslsTests \ContentImport \Importers \PostMeta ;
4
+
5
+ use Brain \Monkey \Functions ;
6
+ use lloc \Msls \ContentImport \ImportCoordinates ;
7
+ use lloc \Msls \ContentImport \Importers \PostMeta \Duplicating ;
8
+ use lloc \MslsTests \MslsUnitTestCase ;
9
+
10
+ use function Brain \Monkey \Functions ;
11
+
12
+ class TestDuplicating extends MslsUnitTestCase {
13
+
14
+ public function testImport (): void {
15
+ Functions \expect ( 'switch_to_blog ' )->twice ();
16
+ Functions \expect ( 'get_post_custom ' )->once ()->andReturn ( array ( 88 => array ( 'foo ' => 'bar ' ) ) );
17
+ Functions \expect ( 'wp_cache_delete ' )->once ();
18
+ Functions \expect ( 'restore_current_blog ' )->once ();
19
+ Functions \expect ( 'delete_post_meta ' )->once ();
20
+ Functions \expect ( 'maybe_unserialize ' )->once ()->andReturnFirstArg ();
21
+ Functions \expect ( 'add_post_meta ' )->once ();
22
+
23
+ $ coordinates = \Mockery::mock ( ImportCoordinates::class );
24
+ $ coordinates ->source_blog_id = 1 ;
25
+ $ coordinates ->source_post_id = 42 ;
26
+ $ coordinates ->dest_blog_id = 2 ;
27
+ $ coordinates ->dest_post_id = 13 ;
28
+
29
+ $ this ->assertEquals ( array (), ( new Duplicating ( $ coordinates ) )->import ( array () ) );
30
+ }
31
+ }
Original file line number Diff line number Diff line change 2
2
3
3
namespace lloc \MslsTests \ContentImport \LogWriters ;
4
4
5
+ use Brain \Monkey \Functions ;
6
+ use lloc \Msls \ContentImport \ImportCoordinates ;
5
7
use lloc \Msls \ContentImport \LogWriters \AdminNoticeLogger ;
6
8
use lloc \MslsTests \MslsUnitTestCase ;
7
9
8
10
class TestAdminNoticeLogger extends MslsUnitTestCase {
9
11
10
-
11
12
public function setUp (): void {
12
13
parent ::setUp ();
13
14
14
15
$ this ->test = new AdminNoticeLogger ();
15
16
}
16
17
17
- public function test_get_transient (): void {
18
+ public function testGetTransient (): void {
18
19
$ this ->assertEquals ( 'msls_last_import_log ' , $ this ->test ->get_transient () );
19
20
}
21
+
22
+ public function testWrite (): void {
23
+ Functions \expect ( 'switch_to_blog ' )->once ();
24
+ Functions \expect ( 'set_transient ' )->once ();
25
+
26
+ $ coordinates = \Mockery::mock ( ImportCoordinates::class );
27
+ $ coordinates ->source_blog_id = 1 ;
28
+ $ coordinates ->source_post_id = 42 ;
29
+ $ coordinates ->dest_blog_id = 2 ;
30
+ $ coordinates ->dest_post_id = 13 ;
31
+
32
+ $ this ->test ->set_import_coordinates ( $ coordinates );
33
+
34
+ $ data = array ( 'info ' , array ( 'foo ' ) );
35
+ $ this ->test ->write ( $ data );
36
+
37
+ $ this ->expectNotToPerformAssertions ();
38
+ }
20
39
}
You can’t perform that action at this time.
0 commit comments