Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Oct 12, 2021
1 parent 3d67fb9 commit 0066269
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 12 deletions.
3 changes: 2 additions & 1 deletion tests/phpunit/integration/tests/Admin/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

namespace Google\Web_Stories\Tests\Integration\Admin;

use Google\Web_Stories\Experiments;
use Google\Web_Stories\Settings;
use Google\Web_Stories\Story_Post_Type;
use Google\Web_Stories\Tests\Integration\Capabilities_Setup;
Expand Down Expand Up @@ -188,7 +189,7 @@ public function test_enqueue_assets() {
$this->createMock( \Google\Web_Stories\Locale::class ),
( new \Google\Web_Stories\Admin\Google_Fonts() ),
$assets,
new Story_Post_Type( new Settings() )
new Story_Post_Type( new Settings(), $experiments )
);

$this->instance->add_menu_page();
Expand Down
11 changes: 6 additions & 5 deletions tests/phpunit/integration/tests/REST_API/Embed_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ public function set_up() {
add_filter( 'pre_http_request', [ $this, 'mock_http_request' ], 10, 3 );
$this->request_count = 0;

$this->controller = new \Google\Web_Stories\REST_API\Embed_Controller( new Story_Post_Type( new Settings() ) );
$settings = new Settings();
$this->controller = new \Google\Web_Stories\REST_API\Embed_Controller(
new Story_Post_Type( $settings, new Experiments( $settings ) )
);
}

public function tear_down() {
Expand Down Expand Up @@ -298,12 +301,11 @@ public function test_local_url_pretty_permalinks() {

$this->set_permalink_structure( '/%postname%/' );

$settings = new Settings();

// Without (re-)registering the post type here there won't be any rewrite rules for it
// and get_permalink() will return "http://example.org/?web-story=embed-controller-test-story"
// instead of "http://example.org/web-stories/embed-controller-test-story/".
// @todo Investigate why this is needed (leakage between tests?)
$settings = new Settings();
$story_post_type = new Story_Post_Type( $settings, new Experiments( $settings ) );
$story_post_type->register();

Expand Down Expand Up @@ -332,12 +334,11 @@ public function test_local_url_pretty_permalinks_multisite() {

$this->set_permalink_structure( '/%postname%/' );

$settings = new Settings();

// Without (re-)registering the post type here there won't be any rewrite rules for it
// and get_permalink() will return "http://example.org/?web-story=embed-controller-test-story"
// instead of "http://example.org/web-stories/embed-controller-test-story/".
// @todo Investigate why this is needed (leakage between tests?).
$settings = new Settings();
$story_post_type = new Story_Post_Type( $settings, new Experiments( $settings ) );
$story_post_type->register();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace Google\Web_Stories\Tests\Integration\REST_API;

use Google\Web_Stories\Experiments;
use Google\Web_Stories\Settings;
use Google\Web_Stories\Story_Post_Type;
use WP_Error;
Expand Down Expand Up @@ -79,8 +80,9 @@ public function set_up() {
add_filter( 'pre_http_request', [ $this, 'mock_http_request' ], 10, 3 );
$this->request_count = 0;

$settings = new Settings();
$this->controller = new \Google\Web_Stories\REST_API\Hotlinking_Controller(
new Story_Post_Type( new Settings() )
new Story_Post_Type( $settings, new Experiments( $settings ) )
);
}

Expand Down
6 changes: 5 additions & 1 deletion tests/phpunit/integration/tests/REST_API/Link_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Google\Web_Stories\Tests\Integration\REST_API;

use Google\Web_Stories\Experiments;
use Google\Web_Stories\Settings;
use Google\Web_Stories\Story_Post_Type;
use Google\Web_Stories\Tests\Integration\Test_REST_TestCase;
Expand Down Expand Up @@ -67,7 +68,10 @@ public function set_up() {
add_filter( 'pre_http_request', [ $this, 'mock_http_request' ], 10, 3 );
$this->request_count = 0;

$this->controller = new \Google\Web_Stories\REST_API\Link_Controller( new Story_Post_Type( new Settings() ) );
$settings = new Settings();
$this->controller = new \Google\Web_Stories\REST_API\Link_Controller(
new Story_Post_Type( $settings, new Experiments( $settings ) )
);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Google\Web_Stories\Tests\Integration\REST_API;

use Google\Web_Stories\Experiments;
use Google\Web_Stories\Settings;
use Google\Web_Stories\Tests\Integration\Story_Post_Type;
use Google\Web_Stories\Tests\Integration\Test_REST_TestCase;
Expand Down Expand Up @@ -94,7 +95,7 @@ public function set_up() {
$settings = new Settings();
$this->controller = new \Google\Web_Stories\REST_API\Publisher_Logos_Controller(
$settings,
new \Google\Web_Stories\Story_Post_Type( $settings )
new \Google\Web_Stories\Story_Post_Type( $settings, new Experiments( $settings ) )
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace Google\Web_Stories\Tests\Integration\REST_API;

use Google\Web_Stories\Experiments;
use Google\Web_Stories\Settings;
use Google\Web_Stories\Story_Post_Type;
use WP_REST_Request;
Expand Down Expand Up @@ -62,8 +63,9 @@ public static function wpSetUpBeforeClass( $factory ) {
public function set_up() {
parent::set_up();

$settings = new Settings();
$this->controller = new \Google\Web_Stories\REST_API\Status_Check_Controller(
new Story_Post_Type( new Settings() )
new Story_Post_Type( $settings, new Experiments( $settings ) )
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace Google\Web_Stories\Tests\Integration\REST_API;

use Google\Web_Stories\Experiments;
use Google\Web_Stories\Settings;
use Google\Web_Stories\Story_Post_Type;
use Google\Web_Stories\Tests\Integration\Test_REST_TestCase;
Expand Down Expand Up @@ -56,8 +57,9 @@ public static function wpSetUpBeforeClass( $factory ) {
public function set_up() {
parent::set_up();

$settings = new Settings();
$this->controller = new \Google\Web_Stories\REST_API\Stories_Autosaves_Controller(
new Story_Post_Type( new Settings() )
new Story_Post_Type( $settings, new Experiments( $settings ) )
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace Google\Web_Stories\Tests\Integration\REST_API;

use Google\Web_Stories\Experiments;
use Google\Web_Stories\Settings;
use Google\Web_Stories\Story_Post_Type;
use Google\Web_Stories\Tests\Integration\Test_REST_TestCase;
Expand Down Expand Up @@ -65,8 +66,9 @@ public static function wpSetUpBeforeClass( $factory ) {
public function set_up() {
parent::set_up();

$settings = new Settings();
$this->controller = new \Google\Web_Stories\REST_API\Stories_Lock_Controller(
new Story_Post_Type( new Settings() )
new Story_Post_Type( $settings, new Experiments( $settings ) )
);
}

Expand Down

0 comments on commit 0066269

Please sign in to comment.