AdminNoticeLoggerTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testWrite() 0 23 1
A testShow_last_log() 0 13 1
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