diff --git a/tests/TestMslsOptionsQueryAuthor.php b/tests/TestMslsOptionsQueryAuthor.php index cf16be36..455295c5 100644 --- a/tests/TestMslsOptionsQueryAuthor.php +++ b/tests/TestMslsOptionsQueryAuthor.php @@ -1,4 +1,4 @@ -assertEquals( null, $obj->get_object( 'test_var' ) ); diff --git a/tests/TestMslsSqlCacher.php b/tests/TestMslsSqlCacher.php index bc6b72d7..361ecb25 100644 --- a/tests/TestMslsSqlCacher.php +++ b/tests/TestMslsSqlCacher.php @@ -1,4 +1,4 @@ -shouldReceive( [ 'prepare' => '', 'get_results' => [] ] ); - return new MslsSqlCacher( $wpdb, 'MslsSqlCacherTest' ); + $this->test = new MslsSqlCacher( $wpdb, 'MslsSqlCacherTest' ); } public function test_set_params_method(): void { Functions\when( 'wp_cache_get' )->justReturn( false ); Functions\when( 'wp_cache_set' )->justReturn( true ); - $obj = $this->get_sut(); + $this->assertInstanceOf( MslsSqlCacher::class, $this->test->set_params( array( 'Cache', 'Test' ) ) ); + $this->assertIsSTring( $this->test->get_key() ); + $this->assertEquals( 'MslsSqlCacherTest_Cache_Test', $this->test->get_key() ); - $this->assertInstanceOf( MslsSqlCacher::class, $obj->set_params( array( 'Cache', 'Test' ) ) ); - $this->assertIsSTring( $obj->get_key() ); - $this->assertEquals( 'MslsSqlCacherTest_Cache_Test', $obj->get_key() ); + $this->assertInstanceOf( MslsSqlCacher::class, $this->test->set_params( 'Cache_Test' ) ); + $this->assertIsSTring( $this->test->get_key() ); + $this->assertEquals( 'MslsSqlCacherTest_Cache_Test', $this->test->get_key() ); - $this->assertInstanceOf( MslsSqlCacher::class, $obj->set_params( 'Cache_Test' ) ); - $this->assertIsSTring( $obj->get_key() ); - $this->assertEquals( 'MslsSqlCacherTest_Cache_Test', $obj->get_key() ); - - $sql = $obj->prepare( - "SELECT blog_id FROM {$obj->blogs} WHERE blog_id != %d AND site_id = %d", - $obj->blogid, - $obj->siteid + $sql = $this->test->prepare( + "SELECT blog_id FROM {$this->test->blogs} WHERE blog_id != %d AND site_id = %d", + $this->test->blogid, + $this->test->siteid ); $this->assertIsSTring( $sql ); - $this->assertIsArray( $obj->get_results( $sql ) ); + $this->assertIsArray( $this->test->get_results( $sql ) ); } } diff --git a/tests/TestMslsTaxonomy.php b/tests/TestMslsTaxonomy.php index 87550c42..1969d62a 100644 --- a/tests/TestMslsTaxonomy.php +++ b/tests/TestMslsTaxonomy.php @@ -1,4 +1,4 @@ -makePartial(); + $this->test = \Mockery::mock( MslsWidget::class )->makePartial(); } public function test_widget(): void { @@ -29,22 +31,18 @@ public function test_widget(): void { Functions\expect( 'get_option' )->andReturn( [] ); Functions\expect( 'msls_blog_collection' )->once()->andReturn( $collection ); - $obj = $this->get_sut(); - $this->expectOutputString( '

Test

No available translations found
' ); - $obj->widget( [], [ 'title' => 'Test' ] ); + $this->test->widget( [], [ 'title' => 'Test' ] ); } public function test_update(): void { - $obj = $this->get_sut(); - - $result = $obj->update( [], [] ); + $result = $this->test->update( [], [] ); $this->assertEquals( [], $result ); - $result = $obj->update( [ 'title' => 'abc' ], [] ); + $result = $this->test->update( [ 'title' => 'abc' ], [] ); $this->assertEquals( [ 'title' => 'abc' ], $result ); - $result = $obj->update( [ 'title' => 'xyz' ], [ 'title' => 'abc' ] ); + $result = $this->test->update( [ 'title' => 'xyz' ], [ 'title' => 'abc' ] ); $this->assertEquals( [ 'title' => 'xyz' ], $result ); }