Skip to content

Commit

Permalink
Merge branch '11.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jun 16, 2024
2 parents 992911f + c211886 commit 713cf8a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Framework/MockObject/Runtime/Api/MutableStubApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public function __phpunit_state(): TestDoubleState
/** @noinspection MagicMethodsValidityInspection */
public function __phpunit_getInvocationHandler(): InvocationHandler
{
return $this->__phpunit_state->invocationHandler();
return $this->__phpunit_state()->invocationHandler();
}

/** @noinspection MagicMethodsValidityInspection */
public function __phpunit_unsetInvocationMocker(): void
{
$this->__phpunit_state->unsetInvocationHandler();
$this->__phpunit_state()->unsetInvocationHandler();
}
}
4 changes: 2 additions & 2 deletions src/Framework/MockObject/Runtime/Api/StubApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public function __phpunit_state(): TestDoubleState
/** @noinspection MagicMethodsValidityInspection */
public function __phpunit_getInvocationHandler(): InvocationHandler
{
return $this->__phpunit_state->invocationHandler();
return $this->__phpunit_state()->invocationHandler();
}

/** @noinspection MagicMethodsValidityInspection */
public function __phpunit_unsetInvocationMocker(): void
{
$this->__phpunit_state->unsetInvocationHandler();
$this->__phpunit_state()->unsetInvocationHandler();
}
}
14 changes: 14 additions & 0 deletions tests/_files/NoTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\TestFixture;

final class NoTestCase
{
}
20 changes: 20 additions & 0 deletions tests/unit/Framework/TestSuiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Small;
use PHPUnit\TestFixture\AbstractTestCase;
use PHPUnit\TestFixture\DependencyFailureTest;
use PHPUnit\TestFixture\DependencyOnClassTest;
use PHPUnit\TestFixture\DependencySuccessTest;
use PHPUnit\TestFixture\MultiDependencyTest;
use PHPUnit\TestFixture\NoTestCase;
use PHPUnit\TestFixture\NotPublicTestCase;
use ReflectionClass;

Expand Down Expand Up @@ -113,4 +115,22 @@ public function testResolverOnlyUsesSuitesAndCases(): void
DependencyFailureTest::class . '::class',
], $suite->requires(), 'Required test names incorrect');
}

public function testRejectsAbstractTestClass(): void
{
$suite = TestSuite::empty('the-test-suite');

$this->expectException(Exception::class);

$suite->addTestSuite(new ReflectionClass(AbstractTestCase::class));
}

public function testRejectsClassThatDoesNotExtendTestClass(): void
{
$suite = TestSuite::empty('the-test-suite');

$this->expectException(Exception::class);

$suite->addTestSuite(new ReflectionClass(NoTestCase::class));
}
}

0 comments on commit 713cf8a

Please sign in to comment.