Skip to content
Merged

Chore #291

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/TestMslsOptionsQueryAuthor.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare( strict_types=1 );

namespace lloc\MslsTests;

Expand Down
2 changes: 1 addition & 1 deletion tests/TestMslsOptionsQueryDay.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare( strict_types=1 );

namespace lloc\MslsTests;

Expand Down
2 changes: 1 addition & 1 deletion tests/TestMslsOptionsQueryMonth.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare( strict_types=1 );

namespace lloc\MslsTests;

Expand Down
2 changes: 1 addition & 1 deletion tests/TestMslsOptionsQueryPostType.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare( strict_types=1 );

namespace lloc\MslsTests;

Expand Down
2 changes: 1 addition & 1 deletion tests/TestMslsOptionsQueryYear.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare( strict_types=1 );

namespace lloc\MslsTests;

Expand Down
2 changes: 1 addition & 1 deletion tests/TestMslsOptionsTax.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare( strict_types=1 );

namespace lloc\MslsTests;

Expand Down
2 changes: 1 addition & 1 deletion tests/TestMslsOptionsTaxTerm.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare( strict_types=1 );

namespace lloc\MslsTests;

Expand Down
2 changes: 1 addition & 1 deletion tests/TestMslsOptionsTaxTermCategory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare( strict_types=1 );

namespace lloc\MslsTests;

Expand Down
2 changes: 1 addition & 1 deletion tests/TestMslsOutput.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare( strict_types=1 );

namespace lloc\MslsTests;

Expand Down
2 changes: 1 addition & 1 deletion tests/TestMslsPlugin.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare( strict_types=1 );

namespace lloc\MslsTests;

Expand Down
2 changes: 1 addition & 1 deletion tests/TestMslsPostTag.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare( strict_types=1 );

namespace lloc\MslsTests;

Expand Down
2 changes: 1 addition & 1 deletion tests/TestMslsPostTagClassic.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare( strict_types=1 );

namespace lloc\MslsTests;

Expand Down
2 changes: 1 addition & 1 deletion tests/TestMslsPostType.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare( strict_types=1 );

namespace lloc\MslsTests;

Expand Down
4 changes: 2 additions & 2 deletions tests/TestMslsRegistry.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
<?php declare( strict_types=1 );

namespace lloc\MslsTests;

use lloc\Msls\MslsRegistry;

class TestMslsRegistry extends MslsUnitTestCase {

function test_set_method() {
public function test_set_method(): void {
$obj = new MslsRegistry();

$this->assertEquals( null, $obj->get_object( 'test_var' ) );
Expand Down
30 changes: 14 additions & 16 deletions tests/TestMslsSqlCacher.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare( strict_types=1 );

namespace lloc\MslsTests;

Expand All @@ -7,37 +7,35 @@

class TestMslsSqlCacher extends MslsUnitTestCase {

public function get_sut(): MslsSqlCacher {
protected function setUp(): void {
$wpdb = \Mockery::mock( \WPDB::class );
$wpdb->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 ) );
}

}
2 changes: 1 addition & 1 deletion tests/TestMslsTaxonomy.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare( strict_types=1 );

namespace lloc\MslsTests;

Expand Down
20 changes: 9 additions & 11 deletions tests/TestMslsWidget.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare( strict_types=1 );

namespace lloc\MslsTests;

Expand All @@ -8,10 +8,12 @@

class TestMslsWidget extends MslsUnitTestCase {

public function get_sut(): MslsWidget {
protected function setUp(): void {
parent::setUp();

\Mockery::mock( '\WP_Widget' );

return \Mockery::mock( MslsWidget::class )->makePartial();
$this->test = \Mockery::mock( MslsWidget::class )->makePartial();
}

public function test_widget(): void {
Expand All @@ -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( '<div><h3>Test</h3>No available translations found</div>' );
$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 );
}

Expand Down