Skip to content

Commit

Permalink
tests: improve AttributesOutputFilter unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
shvlv committed Mar 18, 2024
1 parent 623c5e4 commit 268f66f
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion tests/phpunit/Unit/OutputFilter/AttributesOutputFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,25 @@

class AttributesOutputFilterTest extends AbstractTestCase
{
/**
* phpcs:disable WordPress.PHP.DevelopmentFunctions.prevent_path_disclosure_error_reporting
* phpcs:disable WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_error_reporting
* phpcs:disable WordPress.PHP.DevelopmentFunctions.error_log_set_error_handler
*/
public function testIfTagProcessorIsUnavailable(): void
{
$this->expectDeprecation();
$currentErrorReporting = error_reporting();
error_reporting($currentErrorReporting | \E_USER_DEPRECATED);
$errorMessages = [];

set_error_handler(
static function (int $code, string $msg) use (&$errorMessages): bool {
$errorMessages[] = $msg;
return true;
},
\E_USER_DEPRECATED
);

$testee = new AttributesOutputFilter();

$stub = \Mockery::mock(Asset::class);
Expand All @@ -34,5 +50,12 @@ public function testIfTagProcessorIsUnavailable(): void

static::assertInstanceOf(AssetOutputFilter::class, $testee);
static::assertSame($input, $testee($input, $stub));
static::assertSame(
'Adding attributes is not supported for WordPress < 6.2',
$errorMessages[0]
);

error_reporting($currentErrorReporting);
// phpcs:enable
}
}

0 comments on commit 268f66f

Please sign in to comment.