Skip to content

Commit

Permalink
Closes #5247
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Oct 6, 2024
1 parent b2f75a1 commit a79078c
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 296 deletions.
1 change: 1 addition & 0 deletions ChangeLog-12.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,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()`
* [#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 @@ -18,7 +18,6 @@ This functionality is currently [hard-deprecated](https://phpunit.de/backward-co
| Issue | Description | Since | Replacement |
|-------------------------------------------------------------------|--------------------------------------------------------------------------------|--------|-----------------------------------------------------------------------------------------|
| [#5240](https://github.com/sebastianbergmann/phpunit/issues/5240) | `TestCase::createTestProxy()` | 10.1.0 | |
| [#5241](https://github.com/sebastianbergmann/phpunit/issues/5241) | `TestCase::getMockForAbstractClass()` | 10.1.0 | |
| [#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 | |
Expand Down
16 changes: 0 additions & 16 deletions src/Event/Emitter/DispatchingEmitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,22 +517,6 @@ public function testCreatedMockObjectForTrait(string $traitName): void
);
}

/**
* @param class-string $className
*
* @throws InvalidArgumentException
* @throws UnknownEventTypeException
*/
public function testCreatedMockObjectForAbstractClass(string $className): void
{
$this->dispatcher->dispatch(
new Test\MockObjectForAbstractClassCreated(
$this->telemetryInfo(),
$className,
),
);
}

/**
* @param class-string $originalClassName
* @param class-string $mockClassName
Expand Down
5 changes: 0 additions & 5 deletions src/Event/Emitter/Emitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@ public function testCreatedMockObjectForIntersectionOfInterfaces(array $interfac
*/
public function testCreatedMockObjectForTrait(string $traitName): void;

/**
* @param class-string $className
*/
public function testCreatedMockObjectForAbstractClass(string $className): void;

/**
* @param class-string $originalClassName
* @param class-string $mockClassName
Expand Down

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion src/Event/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ private function registerDefaultTypes(TypeMap $typeMap): void
Test\WarningTriggered::class,

Test\MockObjectCreated::class,
Test\MockObjectForAbstractClassCreated::class,
Test\MockObjectForIntersectionOfInterfacesCreated::class,
Test\MockObjectForTraitCreated::class,
Test\MockObjectFromWsdlCreated::class,
Expand Down
46 changes: 0 additions & 46 deletions src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1478,52 +1478,6 @@ final protected function createTestProxy(string $originalClassName, array $const
return $testProxy;
}

/**
* Creates a mock object for the specified abstract class with all abstract
* methods of the class mocked. Concrete methods are not mocked by default.
* To mock concrete methods, use the 7th parameter ($mockedMethods).
*
* @template RealInstanceType of object
*
* @param class-string<RealInstanceType> $originalClassName
* @param array<mixed> $arguments
* @param list<non-empty-string> $mockedMethods
*
* @throws InvalidArgumentException
* @throws MockObjectException
*
* @return MockObject&RealInstanceType
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/5241
*/
final protected function getMockForAbstractClass(string $originalClassName, array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true, array $mockedMethods = [], bool $cloneArguments = false): MockObject
{
Event\Facade::emitter()->testTriggeredPhpunitDeprecation(
$this->valueObjectForEvents(),
'getMockForAbstractClass() is deprecated and will be removed in PHPUnit 12 without replacement.',
);

$mockObject = (new MockGenerator)->mockObjectForAbstractClass(
$originalClassName,
$arguments,
$mockClassName,
$callOriginalConstructor,
$callOriginalClone,
$callAutoload,
$mockedMethods,
$cloneArguments,
);

$this->registerMockObject($mockObject);

Event\Facade::emitter()->testCreatedMockObjectForAbstractClass($originalClassName);

assert($mockObject instanceof $originalClassName);
assert($mockObject instanceof MockObject);

return $mockObject;
}

/**
* Creates a mock object based on the given WSDL file.
*
Expand Down
36 changes: 0 additions & 36 deletions tests/unit/Event/Emitter/DispatchingEmitterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1138,42 +1138,6 @@ public function notify(Test\MockObjectForTraitCreated $event): void
$this->assertSame($traitName, $event->traitName());
}

public function testTestMockObjectCreatedForAbstractClassDispatchesTestDoubleMockObjectCreatedForAbstractClassEvent(): void
{
$className = stdClass::class;

$subscriber = new class extends RecordingSubscriber implements Test\MockObjectForAbstractClassCreatedSubscriber
{
public function notify(Test\MockObjectForAbstractClassCreated $event): void
{
$this->record($event);
}
};

$dispatcher = $this->dispatcherWithRegisteredSubscriber(
Test\MockObjectForAbstractClassCreatedSubscriber::class,
Test\MockObjectForAbstractClassCreated::class,
$subscriber,
);

$telemetrySystem = $this->telemetrySystem();

$emitter = new DispatchingEmitter(
$dispatcher,
$telemetrySystem,
);

$emitter->testCreatedMockObjectForAbstractClass($className);

$this->assertSame(1, $subscriber->recordedEventCount());

$event = $subscriber->lastRecordedEvent();

$this->assertInstanceOf(Test\MockObjectForAbstractClassCreated::class, $event);

$this->assertSame($className, $event->className());
}

public function testTestMockObjectCreatedFromWsdlDispatchesTestDoubleMockObjectCreatedFromWsdlEvent(): void
{
$wsdlFile = __FILE__;
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit a79078c

Please sign in to comment.