Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wordpressfan committed Dec 9, 2024
1 parent 3585537 commit 02a6057
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Brain\Monkey\Functions;
use Mockery;
use WP_Rocket\Admin\Options_Data;
use WP_Rocket\Engine\Media\Fonts\Context\Context;
use WP_Rocket\Engine\Media\Fonts\Context\OptimizationContext;
use WP_Rocket\Tests\Unit\TestCase;

/**
Expand All @@ -20,7 +20,7 @@ public function testShouldDoExpected( $config, $expected ) {
$this->donotrocketoptimize = $config['do_not_optimize'];

$options = Mockery::mock( Options_Data::class );
$context = new Context( $options );
$context = new OptimizationContext( $options );

Functions\when( 'rocket_bypass' )->justReturn( $config['bypass'] );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@

use Brain\Monkey\Functions;
use Mockery;
use WP_Rocket\Engine\Media\Fonts\Context\OptimizationContext;
use WP_Rocket\Engine\Media\Fonts\Context\SaasContext;
use WP_Rocket\Engine\Media\Fonts\Filesystem as FontsFilesystem;
use WP_Rocket\Engine\Media\Fonts\Frontend\Controller;
use WP_Rocket\Engine\Media\Fonts\Context\Context;
use WP_Rocket\Tests\Unit\FilesystemTestCase;

/**
* @group HostFontsLocally
*/
class Test_RewriteFonts extends FilesystemTestCase {
protected $path_to_test_data = '/inc/Engine/Media/Fonts/Frontend/Controller/rewriteFonts.php';
class Test_RewriteFontsForOptimizations extends FilesystemTestCase {
protected $path_to_test_data = '/inc/Engine/Media/Fonts/Frontend/Controller/rewriteFontsForOptimizations.php';

private $context;
private $optimization_context;
private $saas_context;
private $controller;
private $fonts_filesystem;

Expand All @@ -25,9 +27,10 @@ public function set_up() {

Functions\when( 'get_current_blog_id' )->justReturn( 1 );

$this->context = Mockery::mock( Context::class );
$this->fonts_filesystem = Mockery::mock( FontsFilesystem::class );
$this->controller = new Controller( $this->context, $this->fonts_filesystem );
$this->optimization_context = Mockery::mock( OptimizationContext::class );
$this->saas_context = Mockery::mock( SaasContext::class );
$this->fonts_filesystem = Mockery::mock( FontsFilesystem::class );
$this->controller = new Controller( $this->optimization_context, $this->saas_context, $this->fonts_filesystem );

$this->stubWpParseUrl();
}
Expand All @@ -36,7 +39,7 @@ public function set_up() {
* @dataProvider providerTestData
*/
public function testShouldDoExpected( $config, $original, $expected ) {
$this->context->shouldReceive('is_allowed')
$this->optimization_context->shouldReceive('is_allowed')
->once()
->andReturn( $config['is_allowed'] );

Expand All @@ -60,7 +63,7 @@ public function testShouldDoExpected( $config, $original, $expected ) {

$this->assertSame(
$this->format_the_html( $expected ),
$this->format_the_html( $this->controller->rewrite_fonts( $original ) )
$this->format_the_html( $this->controller->rewrite_fonts_for_optimizations( $original ) )
);
}
}

0 comments on commit 02a6057

Please sign in to comment.