Skip to content
Permalink
Browse files

Merge branch '8.1'

  • Loading branch information...
sebastianbergmann committed May 14, 2019
2 parents ba3417f + 01392d4 commit 220191ddc2606eb993ac2d0ec1f9ddcfbf58f140
Showing with 56 additions and 15 deletions.
  1. +7 −0 ChangeLog-7.5.md
  2. +7 −0 ChangeLog-8.1.md
  3. +32 −14 src/Framework/MockObject/Generator.php
  4. +10 −1 tests/unit/Framework/MockObject/GeneratorTest.php
@@ -2,6 +2,12 @@

All notable changes of the PHPUnit 7.5 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## [7.5.11] - 2019-05-14

### Fixed

* Fixed [#3683](https://github.com/sebastianbergmann/phpunit/issues/3683): Regression in PHPUnit 7.5.10 with regard to Exception stubbing/mocking

## [7.5.10] - 2019-05-09

### Fixed
@@ -102,6 +108,7 @@ All notable changes of the PHPUnit 7.5 release series are documented in this fil
* Fixed [#3429](https://github.com/sebastianbergmann/phpunit/pull/3429): Inefficient loop in `getHookMethods()`
* Fixed [#3437](https://github.com/sebastianbergmann/phpunit/pull/3437): JUnit logger skips PHPT tests

[7.5.11]: https://github.com/sebastianbergmann/phpunit/compare/7.5.10...7.5.11
[7.5.10]: https://github.com/sebastianbergmann/phpunit/compare/7.5.9...7.5.10
[7.5.9]: https://github.com/sebastianbergmann/phpunit/compare/7.5.8...7.5.9
[7.5.8]: https://github.com/sebastianbergmann/phpunit/compare/7.5.7...7.5.8
@@ -2,6 +2,12 @@

All notable changes of the PHPUnit 8.1 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## [8.1.5] - 2019-05-14

### Fixed

* Fixed [#3683](https://github.com/sebastianbergmann/phpunit/issues/3683): Regression in PHPUnit 8.1.4 with regard to Exception stubbing/mocking

## [8.1.4] - 2019-05-09

### Fixed
@@ -47,6 +53,7 @@ All notable changes of the PHPUnit 8.1 release series are documented in this fil

* The `groups` attribute on the `test` element in the TestDox XML report is now deprecated

[8.1.5]: https://github.com/sebastianbergmann/phpunit/compare/8.1.4...8.1.5
[8.1.4]: https://github.com/sebastianbergmann/phpunit/compare/8.1.3...8.1.4
[8.1.3]: https://github.com/sebastianbergmann/phpunit/compare/8.1.2...8.1.3
[8.1.2]: https://github.com/sebastianbergmann/phpunit/compare/8.1.1...8.1.2
@@ -714,31 +714,49 @@ private function generateMock($type, $explicitMethods, string $mockClassName, bo
// @see https://github.com/sebastianbergmann/phpunit/issues/2995
if ($isInterface && $class->implementsInterface(\Throwable::class)) {
$actualClassName = \Exception::class;
$additionalInterfaces[] = $class->getName();
$interfaceOwnMethods = [];
$isInterface = false;
foreach ($this->getInterfaceOwnMethods($mockClassName['fullClassName']) as $method) {
$interfaceOwnMethods[] = MockMethod::fromReflection($method, $callOriginalMethods, $cloneArguments);
}
$mockMethods->addMethods(...$interfaceOwnMethods);
$mockClassName = $this->generateClassName(
\Exception::class,
'',
'Mock_'
);
try {
$class = new \ReflectionClass($mockClassName['fullClassName']);
$class = new \ReflectionClass($actualClassName);
} catch (\ReflectionException $e) {
throw new RuntimeException(
$e->getMessage(),
(int) $e->getCode(),
$e
);
}
foreach ($this->getInterfaceOwnMethods($mockClassName['fullClassName']) as $method) {
$methodName = $method->getName();
if ($class->hasMethod($methodName)) {
try {
$classMethod = $class->getMethod($methodName);
} catch (\ReflectionException $e) {
throw new RuntimeException(
$e->getMessage(),
(int) $e->getCode(),
$e
);
}
if (!$this->canMockMethod($classMethod)) {
continue;
}
}
$mockMethods->addMethods(
MockMethod::fromReflection($method, $callOriginalMethods, $cloneArguments)
);
}
$mockClassName = $this->generateClassName(
$actualClassName,
'',
'Mock_'
);
}
// @see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/103
@@ -185,7 +185,7 @@ public function testCanInvokeMethodsOfNonExistentClass(): void
$this->assertNull($mock->someMethod());
}
public function testMockingOfThrowable(): void
public function testMockingOfExceptionWithThrowable(): void
{
$stub = $this->generator->getMock(ExceptionWithThrowable::class);
@@ -194,6 +194,15 @@ public function testMockingOfThrowable(): void
$this->assertInstanceOf(MockObject::class, $stub);
}
public function testMockingOfThrowable(): void
{
$stub = $this->generator->getMock(Throwable::class);
$this->assertInstanceOf(Throwable::class, $stub);
$this->assertInstanceOf(Exception::class, $stub);
$this->assertInstanceOf(MockObject::class, $stub);
}
public function testVariadicArgumentsArePassedToOriginalMethod(): void
{
/** @var ClassWithVariadicArgumentMethod|MockObject $mock */

0 comments on commit 220191d

Please sign in to comment.
You can’t perform that action at this time.