Skip to content

Commit

Permalink
Closes #5314
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Oct 6, 2024
1 parent a79078c commit 593df34
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 50 deletions.
1 change: 1 addition & 0 deletions ChangeLog-12.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All notable changes of the PHPUnit 12.0 release series are documented in this fi
### Removed

* [#5247](https://github.com/sebastianbergmann/phpunit/issues/5247): `TestCase::getMockForAbstractClass()`
* [#5314](https://github.com/sebastianbergmann/phpunit/issues/5314): `MockBuilder::getMockForAbstractClass()`
* [#5978](https://github.com/sebastianbergmann/phpunit/issues/5978): Support for PHP 8.2

[12.0.0]: https://github.com/sebastianbergmann/phpunit/compare/11.5...main
1 change: 0 additions & 1 deletion DEPRECATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ This functionality is currently [hard-deprecated](https://phpunit.de/backward-co
| [#5242](https://github.com/sebastianbergmann/phpunit/issues/5242) | `TestCase::getMockFromWsdl()` | 10.1.0 | |
| [#5243](https://github.com/sebastianbergmann/phpunit/issues/5243) | `TestCase::getMockForTrait()` | 10.1.0 | |
| [#5244](https://github.com/sebastianbergmann/phpunit/issues/5244) | `TestCase::getObjectForTrait()` | 10.1.0 | |
| [#5305](https://github.com/sebastianbergmann/phpunit/issues/5305) | `MockBuilder::getMockForAbstractClass()` | 10.1.0 | |
| [#5306](https://github.com/sebastianbergmann/phpunit/issues/5306) | `MockBuilder::getMockForTrait()` | 10.1.0 | |
| [#5307](https://github.com/sebastianbergmann/phpunit/issues/5307) | `MockBuilder::disableProxyingToOriginalMethods()` | 10.1.0 | |
| [#5307](https://github.com/sebastianbergmann/phpunit/issues/5307) | `MockBuilder::enableProxyingToOriginalMethods()` | 10.1.0 | |
Expand Down
36 changes: 0 additions & 36 deletions src/Framework/MockObject/MockBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,42 +123,6 @@ public function getMock(): MockObject
return $object;
}

/**
* Creates a mock object for an abstract class using a fluent interface.
*
* @throws Exception
* @throws ReflectionException
* @throws RuntimeException
*
* @return MockedType&MockObject
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/5305
*/
public function getMockForAbstractClass(): MockObject
{
EventFacade::emitter()->testTriggeredPhpunitDeprecation(
$this->testCase->valueObjectForEvents(),
'MockBuilder::getMockForAbstractClass() is deprecated and will be removed in PHPUnit 12 without replacement.',
);

$object = $this->generator->mockObjectForAbstractClass(
$this->type,
$this->constructorArgs,
$this->mockClassName ?? '',
$this->originalConstructor,
$this->originalClone,
$this->autoload,
$this->methods,
$this->cloneArguments,
);

assert($object instanceof MockObject);

$this->testCase->registerMockObject($object);

return $object;
}

/**
* Creates a mock object for a trait using a fluent interface.
*
Expand Down
13 changes: 0 additions & 13 deletions tests/unit/Framework/MockObject/Creation/MockBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
use PHPUnit\Framework\MockObject\Generator\InvalidMethodNameException;
use PHPUnit\Framework\MockObject\Generator\NameAlreadyInUseException;
use PHPUnit\Framework\TestCase;
use PHPUnit\TestFixture\MockObject\AbstractClass;
use PHPUnit\TestFixture\MockObject\ExtendableClass;
use PHPUnit\TestFixture\MockObject\ExtendableClassCallingMethodInConstructor;
use PHPUnit\TestFixture\MockObject\InterfaceWithReturnTypeDeclaration;
Expand Down Expand Up @@ -113,18 +112,6 @@ public function testCannotCreateMockObjectForExtendableClassAddingMethodToItWith
->getMock();
}

#[IgnorePhpunitDeprecations]
#[TestDox('getMockForAbstractClass() can be used to create a mock object for an abstract class')]
public function testCreatesMockObjectForAbstractClassAndAllowsConfigurationOfAbstractMethods(): void
{
$double = $this->getMockBuilder(AbstractClass::class)
->getMockForAbstractClass();

$double->expects($this->once())->method('doSomethingElse')->willReturn(true);

$this->assertTrue($double->doSomething());
}

#[IgnorePhpunitDeprecations]
#[TestDox('getMockForTrait() can be used to create a mock object for a trait')]
public function testCreatesMockObjectForTraitAndAllowsConfigurationOfMethods(): void
Expand Down

0 comments on commit 593df34

Please sign in to comment.