-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate TestCase
methods for creating return stub configuration objects
#5423
Labels
Milestone
Comments
sebastianbergmann
added
feature/test-doubles
Test Stubs and Mock Objects
type/deprecation
Something will be/is deprecated
labels
Jun 24, 2023
sebastianbergmann
added a commit
that referenced
this issue
Jun 24, 2023
Two questions:
|
Because I forgot to, my bad. The deprecations made in PHPUnit 10.3.0 are now documented: https://github.com/sebastianbergmann/phpunit/blob/10.3.2/ChangeLog-10.3.md#deprecated-1 |
I hope this example from PHPUnit's own test suite is enough: final public function testMethodCanBeConfiguredToReturnDifferentValuesOnConsecutiveCalls(): void
{
$double = $this->createTestDouble(InterfaceWithReturnTypeDeclaration::class);
$double->method('doSomething')->willReturn(false, true, false, true);
$this->assertFalse($double->doSomething());
$this->assertTrue($double->doSomething());
$this->assertFalse($double->doSomething());
$this->assertTrue($double->doSomething());
} |
github-merge-queue bot
pushed a commit
to Kitware/CDash
that referenced
this issue
Mar 17, 2024
This PR is meant to serve as a first step for addressing changes that will need to be made before #1866 can be merged. The PHPUnit function `returnCallback()` is [deprecated](sebastianbergmann/phpunit#5423), so our usage of it was switched to its shorthand syntax, as recommended by the docs.
github-merge-queue bot
pushed a commit
to Kitware/CDash
that referenced
this issue
Mar 17, 2024
This PR is meant to serve as a first step for addressing changes that will need to be made before #1866 can be merged. The PHPUnit function `returnCallback()` is [deprecated](sebastianbergmann/phpunit#5423), so our usage of it was switched to its shorthand syntax, as recommended by the docs.
cookieguru
added a commit
to MergePHP/mergephp-website
that referenced
this issue
Apr 13, 2024
* Remove calls to getMockForAbstractClass(), see [1] * Remove calls to PHPUnit method returnValueMap, see [2] * Work around issue with deprecated test_suffix CSV, see [3] * Do not explicitly add `-colors=always` since it is already added [4] [1]: sebastianbergmann/phpunit#5241 [2]: sebastianbergmann/phpunit#5423 [3]: php-actions/phpunit#64 [4]: https://github.com/php-actions/phpunit/blob/c27e49b5fd8cd59d032b7b4441d2e15f23cf6519/phpunit-action.bash#L154
cookieguru
added a commit
to MergePHP/mergephp-website
that referenced
this issue
Apr 13, 2024
* Remove calls to getMockForAbstractClass(), see [1] * Remove calls to PHPUnit method returnValueMap, see [2] * Work around issue with deprecated test_suffix CSV, see [3] * Do not explicitly add `-colors=always` since it is already added [4] [1]: sebastianbergmann/phpunit#5241 [2]: sebastianbergmann/phpunit#5423 [3]: php-actions/phpunit#64 [4]: https://github.com/php-actions/phpunit/blob/c27e49b5fd8cd59d032b7b4441d2e15f23cf6519/phpunit-action.bash#L154
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
To reduce complexity inside PHPUnit's test double functionality, these methods will be deprecated and then removed:
TestCase::returnValue()
(use$double->willReturn()
instead of$double->will($this->returnValue())
)TestCase::onConsecutiveCalls()
(use$double->willReturn()
instead of$double->will($this->onConsecutiveCalls())
)TestCase::returnValueMap()
(use$double->willReturnMap()
instead of$double->will($this->returnValueMap())
)TestCase::returnArgument()
(use$double->willReturnArgument()
instead of$double->will($this->returnArgument())
)TestCase::returnSelf()
(use$double->willReturnSelf()
instead of$double->will($this->returnSelf())
)TestCase::returnCallback()
(use$double->willReturnCallback()
instead of$double->will($this->returnCallback())
)TestCase::throwException()
(use$double->willThrowException()
instead of$double->will($this->throwException())
)Timeline
@deprecated
annotation to the method declaration)The text was updated successfully, but these errors were encountered: