Skip to content

Commit

Permalink
test: add unit tests for types
Browse files Browse the repository at this point in the history
  • Loading branch information
badasswp committed Feb 1, 2025
1 parent 76fdc61 commit cb4f051
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
9 changes: 9 additions & 0 deletions tests/Unit/WP_Mock/TestClass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace WP_Mock\Tests\Unit\WP_Mock;

class TestClass {
public function __construct() {
//Do nothing...
}
}
36 changes: 29 additions & 7 deletions tests/Unit/WP_MockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

namespace WP_Mock\Tests\Unit;

use Generator;
use Mockery;
use Mockery\Exception\InvalidCountException;
use Mockery\ExpectationInterface;
use WP_Mock;
use stdClass;
use Generator;
use PHPUnit\Framework\Exception;
use Mockery\ExpectationInterface;
use WP_Mock\Tests\WP_MockTestCase;
use WP_Mock\DeprecatedMethodListener;
use WP_Mock\Tests\Unit\WP_Mock\TestClass;
use Mockery\Exception\InvalidCountException;
use PHPUnit\Framework\ExpectationFailedException;
use SebastianBergmann\RecursionContext\InvalidArgumentException;
use stdClass;
use WP_Mock;
use WP_Mock\DeprecatedMethodListener;
use WP_Mock\Tests\WP_MockTestCase;

/**
* @covers \WP_Mock
Expand Down Expand Up @@ -222,6 +223,27 @@ public function testAssertFiltersCalledFails(): void
Mockery::close();
}

/**
* @covers \WP_Mock::assertFiltersCalled()
*
* @runInSeparateProcess
* @preserveGlobalState disabled
*
* @return void
*/
public function testAssertFiltersPassesWithTypes(): void
{
WP_Mock::bootstrap();

WP_Mock::expectFilter('testFilter', WP_Mock\Functions::type(TestClass::class));

apply_filters('testFilter', new TestClass());

WP_Mock::assertFiltersCalled();

Mockery::close();
}

/**
* @covers \WP_Mock::alias()
*
Expand Down

0 comments on commit cb4f051

Please sign in to comment.