|
2 | 2 |
|
3 | 3 | namespace lloc\MslsTests;
|
4 | 4 |
|
| 5 | +use lloc\Msls\MslsBlog; |
5 | 6 | use lloc\Msls\MslsBlogCollection;
|
6 | 7 | use lloc\Msls\MslsOutput;
|
7 | 8 | use lloc\Msls\MslsOptions;
|
|
10 | 11 |
|
11 | 12 | class TestMslsOutput extends MslsUnitTestCase {
|
12 | 13 |
|
13 |
| - function get_test() { |
14 |
| - $options = \Mockery::mock( MslsOptions::class ); |
| 14 | + protected function setUp(): void { |
| 15 | + $options = \Mockery::mock( MslsOptions::class ); |
| 16 | + |
15 | 17 | $collection = \Mockery::mock( MslsBlogCollection::class );
|
16 |
| - $collection->shouldReceive( [ |
17 |
| - 'has_current_blog' => true, |
18 |
| - 'get_current_blog' => 1, |
19 |
| - 'get_filtered' => [], |
20 |
| - ] ); |
| 18 | + $collection->shouldReceive( 'has_current_blog' )->andReturn( true ); |
| 19 | + $collection->shouldReceive( 'get_current_blog' )->andReturn( 1 ); |
| 20 | + $collection->shouldReceive( 'get_filtered' )->andReturn( array() ); |
21 | 21 |
|
22 |
| - return new MslsOutput( $options, $collection ); |
| 22 | + $this->test = new MslsOutput( $options, $collection ); |
23 | 23 | }
|
24 | 24 |
|
25 |
| - function test_get_method() { |
26 |
| - $obj = $this->get_test(); |
27 |
| - |
28 |
| - $this->assertIsArray( $obj->get( 0 ) ); |
| 25 | + public function test_get_method(): void { |
| 26 | + $this->assertEquals( array(), $this->test->get( 0 ) ); |
29 | 27 | }
|
30 | 28 |
|
31 |
| - function test___toString_method() { |
32 |
| - $obj = $this->get_test(); |
| 29 | + public function test_get_alternate_links() { |
| 30 | + $blog = \Mockery::mock( MslsBlog::class ); |
| 31 | + $blog->shouldReceive( 'get_alpha2' )->andReturn( 'de' ); |
| 32 | + $blog->shouldReceive( 'get_language' )->andReturn( 'de_DE' ); |
33 | 33 |
|
34 |
| - $this->assertIsSTring( $obj->__toString() ); |
35 |
| - $this->assertIsSTring( strval( $obj ) ); |
36 |
| - $this->assertEquals( $obj->__toString(), strval( $obj ) ); |
37 |
| - } |
| 34 | + $collection = \Mockery::mock( MslsBlogCollection::class ); |
| 35 | + $collection->shouldReceive( 'get_objects' )->andReturn( array( $blog ) ); |
38 | 36 |
|
39 |
| - function test_get_tags_method() { |
40 |
| - $obj = $this->get_test(); |
| 37 | + Functions\expect( 'msls_blog_collection' )->once()->andReturn( $collection ); |
| 38 | + Functions\expect( 'is_admin' )->once()->andReturn( false ); |
| 39 | + Functions\expect( 'is_front_page' )->once()->andReturn( false ); |
| 40 | + Functions\expect( 'is_search' )->once()->andReturn( false ); |
| 41 | + Functions\expect( 'is_404' )->once()->andReturn( false ); |
41 | 42 |
|
42 |
| - $this->assertIsArray( $obj->get_tags() ); |
| 43 | + $this->assertEquals( array(), $this->test->get_alternate_links() ); |
43 | 44 | }
|
44 | 45 |
|
45 |
| - function test_set_tags_method() { |
46 |
| - Functions\expect( 'wp_parse_args' )->once()->andReturn( [] ); |
47 |
| - |
48 |
| - $obj = $this->get_test(); |
| 46 | + public function test___toString() { |
| 47 | + $this->assertIsSTring( $this->test->__toString() ); |
| 48 | + $this->assertIsSTring( strval( $this->test ) ); |
| 49 | + $this->assertEquals( $this->test->__toString(), strval( $this->test ) ); |
| 50 | + } |
49 | 51 |
|
50 |
| - $this->assertInstanceOf( MslsOutput::class, $obj->set_tags() ); |
| 52 | + public function test_get_tags(): void { |
| 53 | + $this->assertIsArray( $this->test->get_tags() ); |
51 | 54 | }
|
52 | 55 |
|
53 |
| - function test_is_requirements_not_fulfilled_method_with_null() { |
54 |
| - $obj = $this->get_test(); |
| 56 | + public function test_set_tags(): void { |
| 57 | + Functions\expect( 'wp_parse_args' )->once()->andReturn( array() ); |
55 | 58 |
|
56 |
| - $test = $obj->is_requirements_not_fulfilled( null, false, 'de_DE' ); |
57 |
| - $this->assertFalse( $test ); |
| 59 | + $this->assertInstanceOf( MslsOutput::class, $this->test->set_tags() ); |
| 60 | + } |
58 | 61 |
|
59 |
| - $test = $obj->is_requirements_not_fulfilled( null, true, 'de_DE' ); |
60 |
| - $this->assertTrue( $test ); |
| 62 | + public function test_is_requirements_not_fulfilled_with_null(): void { |
| 63 | + $this->assertFalse( $this->test->is_requirements_not_fulfilled( null, false, 'de_DE' ) ); |
| 64 | + $this->assertTrue( $this->test->is_requirements_not_fulfilled( null, true, 'de_DE' ) ); |
61 | 65 | }
|
62 | 66 |
|
63 |
| - function test_is_requirements_not_fulfilled_method_with_mslsoptions() { |
64 |
| - Functions\expect( 'get_option' )->once()->andReturn( [] ); |
| 67 | + public function test_is_requirements_not_fulfilled_with_mslsoptions(): void { |
| 68 | + Functions\expect( 'get_option' )->once()->andReturn( array() ); |
65 | 69 |
|
66 | 70 | $mydata = new MslsOptions();
|
67 | 71 |
|
68 |
| - $obj = $this->get_test(); |
69 |
| - |
70 |
| - $test = $obj->is_requirements_not_fulfilled( $mydata, false, 'de_DE' ); |
71 |
| - $this->assertFalse( $test ); |
72 |
| - |
73 |
| - $test = $obj->is_requirements_not_fulfilled( $mydata, true, 'de_DE' ); |
74 |
| - $this->assertFalse( $test ); |
| 72 | + $this->assertFalse( $this->test->is_requirements_not_fulfilled( $mydata, false, 'de_DE' ) ); |
| 73 | + $this->assertFalse( $this->test->is_requirements_not_fulfilled( $mydata, true, 'de_DE' ) ); |
75 | 74 | }
|
76 | 75 |
|
77 |
| - function test_is_requirements_not_fulfilled_method_with_mslsoptionspost() { |
78 |
| - Functions\expect( 'get_option' )->once()->andReturn( [] ); |
| 76 | + public function test_is_requirements_not_fulfilled_with_mslsoptionspost(): void { |
| 77 | + Functions\expect( 'get_option' )->once()->andReturn( array() ); |
79 | 78 |
|
80 | 79 | $mydata = new MslsOptionsPost();
|
81 | 80 |
|
82 |
| - $obj = $this->get_test(); |
83 |
| - |
84 |
| - $test = $obj->is_requirements_not_fulfilled( $mydata, false, 'de_DE' ); |
85 |
| - $this->assertFalse( $test ); |
86 |
| - |
87 |
| - $test = $obj->is_requirements_not_fulfilled( $mydata, true, 'de_DE' ); |
88 |
| - $this->assertTrue( $test ); |
| 81 | + $this->assertFalse( $this->test->is_requirements_not_fulfilled( $mydata, false, 'de_DE' ) ); |
| 82 | + $this->assertTrue( $this->test->is_requirements_not_fulfilled( $mydata, true, 'de_DE' ) ); |
89 | 83 | }
|
90 |
| - |
91 | 84 | }
|
0 commit comments