Skip to content

Commit

Permalink
Closes #4564
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Dec 28, 2020
1 parent fa6c3e4 commit dbba41d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 125 deletions.
1 change: 1 addition & 0 deletions ChangeLog-10.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ All notable changes of the PHPUnit 10.0 release series are documented in this fi
* [#4397](https://github.com/sebastianbergmann/phpunit/issues/4397): Remove confusing parameter options for XML assertions
* [#4531](https://github.com/sebastianbergmann/phpunit/pull/4531): Remove `--loader` option as well as `testSuiteLoaderClass` and `testSuiteLoaderFile` XML configuration settings
* [#4536](https://github.com/sebastianbergmann/phpunit/issues/4536): Remove `assertFileNotIsWritable()`
* [#4564](https://github.com/sebastianbergmann/phpunit/issues/4564): Deprecate `withConsecutive()`
* [#4567](https://github.com/sebastianbergmann/phpunit/issues/4567): Deprecate support for generators in `assertCount()` and `Count` constraint
* Removed the `PHPUnit\Runner\TestSuiteLoader` interface

Expand Down
18 changes: 18 additions & 0 deletions src/Framework/MockObject/Builder/InvocationMocker.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use function array_map;
use function array_merge;
use function count;
use function debug_backtrace;
use function in_array;
use function is_string;
use function strtolower;
Expand All @@ -35,6 +36,7 @@
use PHPUnit\Framework\MockObject\Stub\ReturnStub;
use PHPUnit\Framework\MockObject\Stub\ReturnValueMap;
use PHPUnit\Framework\MockObject\Stub\Stub;
use PHPUnit\Framework\TestCase;
use Throwable;

/**
Expand Down Expand Up @@ -188,11 +190,27 @@ public function with(...$arguments): self
* @throws MethodParametersAlreadyConfiguredException
*
* @return $this
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/4564
*/
public function withConsecutive(...$arguments): self
{
$this->ensureParametersCanBeConfigured();

$stack = debug_backtrace();

while (!empty($stack)) {
$frame = array_pop($stack);

if (isset($frame['object']) && $frame['object'] instanceof TestCase) {
$frame['object']->addWarning(
'The withConsecutive() method has been deprecated. It will be removed in PHPUnit 11.'
);

break;
}
}

$this->matcher->setParametersRule(new Rule\ConsecutiveParameters($arguments));

return $this;
Expand Down
14 changes: 0 additions & 14 deletions tests/unit/Framework/MockObject/Builder/InvocationMockerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,6 @@ public function testWillReturnWithMultipleValues(): void
$this->assertEquals(3, $mock->foo());
}

public function testWillReturnOnConsecutiveCalls(): void
{
$mock = $this->getMockBuilder(stdClass::class)
->addMethods(['foo'])
->getMock();

$mock->method('foo')
->willReturnOnConsecutiveCalls(1, 2, 3);

$this->assertEquals(1, $mock->foo());
$this->assertEquals(2, $mock->foo());
$this->assertEquals(3, $mock->foo());
}

public function testWillReturnByReference(): void
{
$mock = $this->getMockBuilder(stdClass::class)
Expand Down

This file was deleted.

23 changes: 0 additions & 23 deletions tests/unit/Framework/MockObject/MockObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,29 +319,6 @@ public function testStubbedReturnSelf(): void
$this->assertEquals($mock, $mock->doSomething());
}

public function testStubbedReturnOnConsecutiveCalls(): void
{
$mock = $this->getMockBuilder(AnInterface::class)
->getMock();

$mock->method('doSomething')
->will($this->onConsecutiveCalls('a', 'b', 'c'));

$this->assertEquals('a', $mock->doSomething());
$this->assertEquals('b', $mock->doSomething());
$this->assertEquals('c', $mock->doSomething());

$mock = $this->getMockBuilder(AnInterface::class)
->getMock();

$mock->method('doSomething')
->willReturnOnConsecutiveCalls('a', 'b', 'c');

$this->assertEquals('a', $mock->doSomething());
$this->assertEquals('b', $mock->doSomething());
$this->assertEquals('c', $mock->doSomething());
}

public function testStaticMethodCallback(): void
{
$mock = $this->getMockBuilder(SomeClass::class)
Expand Down

0 comments on commit dbba41d

Please sign in to comment.