|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace lloc\Msls\ContentImport\LogWriters; |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
use lloc\Msls\ContentImport\ImportCoordinates; |
|
7
|
|
|
|
|
8
|
|
|
class AdminNoticeLoggerTest extends \Msls_UnitTestCase { |
|
9
|
|
|
|
|
10
|
|
|
public function testWrite() { |
|
11
|
|
|
$data = [ |
|
12
|
|
|
'info' => [ 'something' ], |
|
13
|
|
|
]; |
|
14
|
|
|
$import_coordinates = new ImportCoordinates(); |
|
15
|
|
|
$import_coordinates->source_blog_id = $this->factory()->blog->create(); |
|
16
|
|
|
$import_coordinates->dest_blog_id = $this->factory()->blog->create(); |
|
17
|
|
|
switch_to_blog( $import_coordinates->source_blog_id ); |
|
18
|
|
|
$import_coordinates->source_post_id = $this->factory()->post->create(); |
|
19
|
|
|
switch_to_blog( $import_coordinates->dest_blog_id ); |
|
20
|
|
|
$import_coordinates->dest_post_id = $this->factory()->post->create(); |
|
21
|
|
|
|
|
22
|
|
|
$logger = new AdminNoticeLogger(); |
|
23
|
|
|
|
|
24
|
|
|
get_transient( $logger->get_transient() ); |
|
25
|
|
|
|
|
26
|
|
|
$logger->set_import_coordinates( $import_coordinates ); |
|
27
|
|
|
$logger->write( $data ); |
|
28
|
|
|
|
|
29
|
|
|
$html = get_transient( $logger->get_transient() ); |
|
30
|
|
|
$this->assertNotEmpty( $html ); |
|
31
|
|
|
$this->assertInternalType( 'string', $html ); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function testShow_last_log() { |
|
35
|
|
|
$logger = new AdminNoticeLogger(); |
|
36
|
|
|
$output = $logger->show_last_log( false ); |
|
37
|
|
|
|
|
38
|
|
|
$this->assertEmpty( $output ); |
|
39
|
|
|
|
|
40
|
|
|
set_transient( $logger->get_transient(), 'foo-bar' ); |
|
41
|
|
|
|
|
42
|
|
|
$output = $logger->show_last_log( false ); |
|
43
|
|
|
$this->assertEquals( 'foo-bar', $output ); |
|
44
|
|
|
|
|
45
|
|
|
$this->assertEmpty( get_transient( $logger->get_transient() ) ); |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|