Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Miraeld committed Nov 14, 2024
1 parent aef0d3b commit 8578b5f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 4 additions & 3 deletions inc/Engine/Media/Fonts/Frontend/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ class Controller {
* Constructor.
*
* @param Context $context Context instance.
* @param WP_Filesystem_Direct $filesystem WordPress filesystem.
* @param WP_Filesystem_Direct|null $filesystem WordPress filesystem.
*/
public function __construct( Context $context, WP_Filesystem_Direct $filesystem ) {
public function __construct(Context $context, ?WP_Filesystem_Direct $filesystem ) {
$this->context = $context;
$this->base_path = rocket_get_constant( 'WP_ROCKET_CACHE_ROOT_PATH', '' ) . 'fonts/' . get_current_blog_id() . '/';
$this->base_url = rocket_get_constant( 'WP_ROCKET_CACHE_ROOT_URL', '' ) . 'fonts/' . get_current_blog_id() . '/';
$this->filesystem = $filesystem;
$this->filesystem = ! empty( $filesystem ) ? $filesystem : rocket_direct_filesystem();

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use WP_Rocket\Engine\Media\Fonts\Frontend\Controller;
use WP_Rocket\Engine\Media\Fonts\Context\Context;
use WP_Rocket\Tests\Unit\FilesystemTestCase;
use WP_Filesystem_Direct;

/**
* @group HostFontsLocally
Expand All @@ -17,13 +18,16 @@ class TestRewriteFonts extends FilesystemTestCase {
private $context;
private $controller;

protected $filesystem;

public function set_up() {
parent::set_up();

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

$this->context = Mockery::mock( Context::class );
$this->controller = new Controller( $this->context );
$this->filesystem = Mockery::mock( WP_Filesystem_Direct::class );

Check failure on line 29 in tests/Unit/inc/Engine/Media/Fonts/Frontend/Controller/rewriteFonts.php

View workflow job for this annotation

GitHub Actions / WPRocket lint with PHP Stan. PHP 8.2 on ubuntu-latest.

Property WP_Rocket\Tests\Unit\inc\Engine\Media\Fonts\Frontend\Controller\TestRewriteFonts::$filesystem (WPMedia\PHPUnit\VirtualFilesystemDirect) does not accept Mockery\MockInterface&WP_Filesystem_Direct.
$this->controller = new Controller( $this->context, $this->filesystem );

$this->stubWpParseUrl();
}
Expand Down

0 comments on commit 8578b5f

Please sign in to comment.