Skip to content
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::getMockForAbstractClass() #5241

Closed
sebastianbergmann opened this issue Feb 23, 2023 · 0 comments
Closed

Deprecate TestCase::getMockForAbstractClass() #5241

sebastianbergmann opened this issue Feb 23, 2023 · 0 comments
Assignees
Labels
feature/test-doubles Stubs and Mock Objects type/deprecation Something will be/is deprecated
Milestone

Comments

@sebastianbergmann
Copy link
Owner

sebastianbergmann commented Feb 23, 2023

PHPUnit can automatically generate test stubs and mock objects (test doubles) based on interfaces and classes.

When it comes to doubling classes, there are limitations:

  • final, private, and static methods cannot be doubled; they retain their original behavior except for static methods which will be replaced by a method throwing an exception
  • Enumerations (enum) are final classes and therefore cannot be doubled
  • readonly classes cannot be extended by classes that are not readonly and therefore cannot be doubled

Not only because of the limitations mentioned above, but also to improve your software design, PHPUnit's documentation recommends to favour the doubling of interfaces over the doubling of classes.

For quite a while, PHPUnit has offered the createStub() and createMock() methods for creating test stubs and mock objects with best practice defaults. Furthermore, alternatives such as getMockForAbstractClass() exist, but not all of them offer the same clear separation between test double and mock object. For instance, no method named getStubForAbstractClass() exists. Such an inconsistency can lead to confusion.

As its name suggests, the getMockForAbstractClass() method can be used to create a mock object for an abstract class: a mock object where all abstract methods of the original class are implemented in such a way that they can be configured to return a specified value, for instance, or to expect an invocation.

Having to use getMockForAbstractClass() to test something is almost always a code smell: something is not quite right with the software design of the system-under-test.

To promote better software design, improve the readability of test code, and to reduce complexity inside PHPUnit's test double functionality, TestCase::getMockForAbstractClass() will be deprecated and then removed:

  • soft deprecation in PHPUnit 10.1 (add @deprecated annotation to the method declaration)
  • deprecation in PHPUnit 11 (using the method will trigger a deprecation)
  • removal in PHPUnit 12
@sebastianbergmann sebastianbergmann added type/backward-compatibility Something will be/is intentionally broken feature/test-doubles Stubs and Mock Objects labels Feb 23, 2023
@sebastianbergmann sebastianbergmann added this to the PHPUnit 11.0 milestone Feb 23, 2023
@sebastianbergmann sebastianbergmann self-assigned this Feb 23, 2023
sebastianbergmann added a commit to sebastianbergmann/phpunit-documentation-english that referenced this issue Feb 24, 2023
@sebastianbergmann sebastianbergmann changed the title Deprecate TestCase::getMockForAbstractClass() Deprecate TestCase::getMockForAbstractClass() Mar 6, 2023
@sebastianbergmann sebastianbergmann added type/deprecation Something will be/is deprecated and removed type/backward-compatibility Something will be/is intentionally broken labels Apr 11, 2023
morozov added a commit to morozov/dbal that referenced this issue Jun 14, 2023
morozov added a commit to morozov/dbal that referenced this issue Jun 14, 2023
morozov added a commit to morozov/dbal that referenced this issue Jun 16, 2023
See: sebastianbergmann/phpunit#5241

It covers a platform-specific use case in the base platform class,
which is pointless.
reviewtypo3org pushed a commit to TYPO3/typo3 that referenced this issue Aug 8, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow current best practices.

This changes tackles the classes where we can mock an interface
instead of an abstract class, allowing us to use `createMock` instead
of `getMockForAbstractClass`.

Resolves: #101609
Related: #101601
Releases: main, 12.4
Change-Id: I995f70d779a1bc6251bc4479c3dcb2ee548314f1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80455
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan B�rk <stefan@buerk.tech>
Tested-by: Stefan B�rk <stefan@buerk.tech>
reviewtypo3org pushed a commit to TYPO3/typo3 that referenced this issue Aug 8, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow current best practices.

This changes tackles the classes where we can mock an interface
instead of an abstract class, allowing us to use `createMock` instead
of `getMockForAbstractClass`.

Resolves: #101609
Related: #101601
Releases: main, 12.4
Change-Id: I995f70d779a1bc6251bc4479c3dcb2ee548314f1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80458
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
TYPO3IncTeam pushed a commit to TYPO3-CMS/core that referenced this issue Aug 8, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow current best practices.

This changes tackles the classes where we can mock an interface
instead of an abstract class, allowing us to use `createMock` instead
of `getMockForAbstractClass`.

Resolves: #101609
Related: #101601
Releases: main, 12.4
Change-Id: I995f70d779a1bc6251bc4479c3dcb2ee548314f1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80458
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
TYPO3IncTeam pushed a commit to TYPO3-CMS/fluid that referenced this issue Aug 8, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow current best practices.

This changes tackles the classes where we can mock an interface
instead of an abstract class, allowing us to use `createMock` instead
of `getMockForAbstractClass`.

Resolves: #101609
Related: #101601
Releases: main, 12.4
Change-Id: I995f70d779a1bc6251bc4479c3dcb2ee548314f1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80458
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
TYPO3IncTeam pushed a commit to TYPO3-CMS/form that referenced this issue Aug 8, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow current best practices.

This changes tackles the classes where we can mock an interface
instead of an abstract class, allowing us to use `createMock` instead
of `getMockForAbstractClass`.

Resolves: #101609
Related: #101601
Releases: main, 12.4
Change-Id: I995f70d779a1bc6251bc4479c3dcb2ee548314f1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80458
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
TYPO3IncTeam pushed a commit to TYPO3-CMS/core that referenced this issue Aug 8, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow current best practices.

This changes tackles the classes where we can mock an interface
instead of an abstract class, allowing us to use `createMock` instead
of `getMockForAbstractClass`.

Resolves: #101609
Related: #101601
Releases: main, 12.4
Change-Id: I995f70d779a1bc6251bc4479c3dcb2ee548314f1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80455
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan B�rk <stefan@buerk.tech>
Tested-by: Stefan B�rk <stefan@buerk.tech>
TYPO3IncTeam pushed a commit to TYPO3-CMS/fluid that referenced this issue Aug 8, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow current best practices.

This changes tackles the classes where we can mock an interface
instead of an abstract class, allowing us to use `createMock` instead
of `getMockForAbstractClass`.

Resolves: #101609
Related: #101601
Releases: main, 12.4
Change-Id: I995f70d779a1bc6251bc4479c3dcb2ee548314f1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80455
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan B�rk <stefan@buerk.tech>
Tested-by: Stefan B�rk <stefan@buerk.tech>
TYPO3IncTeam pushed a commit to TYPO3-CMS/form that referenced this issue Aug 8, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow current best practices.

This changes tackles the classes where we can mock an interface
instead of an abstract class, allowing us to use `createMock` instead
of `getMockForAbstractClass`.

Resolves: #101609
Related: #101601
Releases: main, 12.4
Change-Id: I995f70d779a1bc6251bc4479c3dcb2ee548314f1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80455
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan B�rk <stefan@buerk.tech>
Tested-by: Stefan B�rk <stefan@buerk.tech>
reviewtypo3org pushed a commit to TYPO3/typo3 that referenced this issue Aug 10, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow best practices and
avoid deprecation warnings later with PHPUnit 11.

We do this by creating dedicated fixture subclasses of the affected
abstract classes.

Resolves: #101630
Related: #101601
Releases: main
Change-Id: I27f526cb7ee4e1f2081c05befd3d70549dd0e2fd
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80470
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Andreas Nedbal <andy@pixelde.su>
Reviewed-by: Lina Wolf <112@linawolf.de>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Lina Wolf <112@linawolf.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Andreas Nedbal <andy@pixelde.su>
TYPO3IncTeam pushed a commit to TYPO3-CMS/core that referenced this issue Aug 10, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow best practices and
avoid deprecation warnings later with PHPUnit 11.

We do this by creating dedicated fixture subclasses of the affected
abstract classes.

Resolves: #101630
Related: #101601
Releases: main
Change-Id: I27f526cb7ee4e1f2081c05befd3d70549dd0e2fd
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80470
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Andreas Nedbal <andy@pixelde.su>
Reviewed-by: Lina Wolf <112@linawolf.de>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Lina Wolf <112@linawolf.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Andreas Nedbal <andy@pixelde.su>
reviewtypo3org pushed a commit to TYPO3/typo3 that referenced this issue Aug 16, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow best practices and
avoid deprecation warnings later with PHPUnit 11.

We do this by creating dedicated fixture subclasses of the affected
abstract classes.

Resolves: #101666
Related: #101601
Releases: main
Change-Id: I0263ff7b0639d72ba1d4f30e3bee12276d364591
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80526
Reviewed-by: Stefan B�rk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Nikita Hovratov <nikita.h@live.de>
Tested-by: Nikita Hovratov <nikita.h@live.de>
Tested-by: Stefan B�rk <stefan@buerk.tech>
TYPO3IncTeam pushed a commit to TYPO3-CMS/core that referenced this issue Aug 16, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow best practices and
avoid deprecation warnings later with PHPUnit 11.

We do this by creating dedicated fixture subclasses of the affected
abstract classes.

Resolves: #101666
Related: #101601
Releases: main
Change-Id: I0263ff7b0639d72ba1d4f30e3bee12276d364591
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80526
Reviewed-by: Stefan B�rk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Nikita Hovratov <nikita.h@live.de>
Tested-by: Nikita Hovratov <nikita.h@live.de>
Tested-by: Stefan B�rk <stefan@buerk.tech>
TYPO3IncTeam pushed a commit to TYPO3-CMS/form that referenced this issue Aug 28, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow best practices and
avoid deprecation warnings later with PHPUnit 11.

We do this by creating dedicated fixture subclasses of the affected
abstract classes.

Resolves: #101661
Related: #101601
Releases: main
Change-Id: I3b9ba4511620aebf125ff207428adc5483d47154
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80522
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Stefan B�rk <stefan@buerk.tech>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Stefan B�rk <stefan@buerk.tech>
oliverklee added a commit to oliverklee/typo3-testing-framework that referenced this issue Aug 28, 2023
This method uses `getMockForAbstractClass()` under the hood, which in turn
has been soft-deprecated in PHPUnit 10.1 and will issue deprecation
warnings in PHPUnit 11 and up:

sebastianbergmann/phpunit#5241

Releases: main
oliverklee added a commit to oliverklee/typo3-testing-framework that referenced this issue Aug 28, 2023
This method uses `getMockForAbstractClass()` under the hood, which in turn
has been soft-deprecated in PHPUnit 10.1 and will issue deprecation
warnings in PHPUnit 11 and up:

sebastianbergmann/phpunit#5241

Releases: main
oliverklee added a commit to oliverklee/typo3-testing-framework that referenced this issue Aug 28, 2023
This method uses `getMockForAbstractClass()` under the hood, which in turn
has been soft-deprecated in PHPUnit 10.1 and will issue deprecation
warnings in PHPUnit 11 and up:

sebastianbergmann/phpunit#5241

Releases: main
sbuerk pushed a commit to TYPO3/testing-framework that referenced this issue Aug 29, 2023
This method uses `getMockForAbstractClass()` under the hood, which in turn
has been soft-deprecated in PHPUnit 10.1 and will issue deprecation
warnings in PHPUnit 11 and up:

sebastianbergmann/phpunit#5241

Releases: main
reviewtypo3org pushed a commit to TYPO3/typo3 that referenced this issue Sep 11, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow best practices and
avoid deprecation warnings later with PHPUnit 11.

We do this by creating dedicated fixture subclasses of the affected
abstract classes.

Resolves: #101892
Related: #101601
Releases: main, 12.4
Change-Id: Id1977130c5e2a9bdc54fb92aea7dfc63ecf55724
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80940
Tested-by: Benjamin Franzke <ben@bnf.dev>
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: core-ci <typo3@b13.com>
reviewtypo3org pushed a commit to TYPO3/typo3 that referenced this issue Sep 11, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow best practices and
avoid deprecation warnings later with PHPUnit 11.

We do this by creating dedicated fixture subclasses of the affected
abstract classes.

Resolves: #101892
Related: #101601
Releases: main, 12.4
Change-Id: Id1977130c5e2a9bdc54fb92aea7dfc63ecf55724
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80952
Tested-by: Benjamin Franzke <ben@bnf.dev>
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: core-ci <typo3@b13.com>
TYPO3IncTeam pushed a commit to TYPO3-CMS/core that referenced this issue Sep 11, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow best practices and
avoid deprecation warnings later with PHPUnit 11.

We do this by creating dedicated fixture subclasses of the affected
abstract classes.

Resolves: #101892
Related: #101601
Releases: main, 12.4
Change-Id: Id1977130c5e2a9bdc54fb92aea7dfc63ecf55724
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80940
Tested-by: Benjamin Franzke <ben@bnf.dev>
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: core-ci <typo3@b13.com>
TYPO3IncTeam pushed a commit to TYPO3-CMS/core that referenced this issue Sep 11, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow best practices and
avoid deprecation warnings later with PHPUnit 11.

We do this by creating dedicated fixture subclasses of the affected
abstract classes.

Resolves: #101892
Related: #101601
Releases: main, 12.4
Change-Id: Id1977130c5e2a9bdc54fb92aea7dfc63ecf55724
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80952
Tested-by: Benjamin Franzke <ben@bnf.dev>
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: core-ci <typo3@b13.com>
reviewtypo3org pushed a commit to TYPO3/typo3 that referenced this issue Sep 11, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow best practices and
avoid deprecation warnings later with PHPUnit 11.

We do this by creating dedicated fixture subclasses of the affected
abstract classes.

Resolves: #101661
Related: #101601
Releases: main, 12.4
Change-Id: I3b9ba4511620aebf125ff207428adc5483d47154
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80944
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: core-ci <typo3@b13.com>
reviewtypo3org pushed a commit to TYPO3/typo3 that referenced this issue Sep 11, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow best practices and
avoid deprecation warnings later with PHPUnit 11.

We do this by creating dedicated fixture subclasses of the affected
abstract classes.

Resolves: #101630
Related: #101601
Releases: main, 12.4
Change-Id: I27f526cb7ee4e1f2081c05befd3d70549dd0e2fd
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80945
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benjamin Franzke <ben@bnf.dev>
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
reviewtypo3org pushed a commit to TYPO3/typo3 that referenced this issue Sep 11, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow best practices and
avoid deprecation warnings later with PHPUnit 11.

We do this by creating dedicated fixture subclasses of the affected
abstract classes.

Resolves: #101666
Related: #101601
Releases: main, 12.4
Change-Id: I0263ff7b0639d72ba1d4f30e3bee12276d364591
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80946
Tested-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
TYPO3IncTeam pushed a commit to TYPO3-CMS/core that referenced this issue Sep 11, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow best practices and
avoid deprecation warnings later with PHPUnit 11.

We do this by creating dedicated fixture subclasses of the affected
abstract classes.

Resolves: #101630
Related: #101601
Releases: main, 12.4
Change-Id: I27f526cb7ee4e1f2081c05befd3d70549dd0e2fd
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80945
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benjamin Franzke <ben@bnf.dev>
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
TYPO3IncTeam pushed a commit to TYPO3-CMS/form that referenced this issue Sep 11, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow best practices and
avoid deprecation warnings later with PHPUnit 11.

We do this by creating dedicated fixture subclasses of the affected
abstract classes.

Resolves: #101661
Related: #101601
Releases: main, 12.4
Change-Id: I3b9ba4511620aebf125ff207428adc5483d47154
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80944
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: core-ci <typo3@b13.com>
TYPO3IncTeam pushed a commit to TYPO3-CMS/core that referenced this issue Sep 11, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow best practices and
avoid deprecation warnings later with PHPUnit 11.

We do this by creating dedicated fixture subclasses of the affected
abstract classes.

Resolves: #101666
Related: #101601
Releases: main, 12.4
Change-Id: I0263ff7b0639d72ba1d4f30e3bee12276d364591
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80946
Tested-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
reviewtypo3org pushed a commit to TYPO3/typo3 that referenced this issue Oct 15, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow best practices and
avoid deprecation warnings later with PHPUnit 11.

We do this by creating dedicated fixture subclasses of the affected
abstract classes.

This change also cleans up the affected test to better match the
setup/execute/verify structure.

Resolves: #102117
Related: #101601
Releases: main, 12.4
Change-Id: Iaa6cee9893d41cb95e20cda80e03f044d52d82cd
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81350
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
reviewtypo3org pushed a commit to TYPO3/typo3 that referenced this issue Oct 15, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow best practices and
avoid deprecation warnings later with PHPUnit 11.

We do this by creating dedicated fixture subclasses of the affected
abstract classes.

This change also cleans up the affected test to better match the
setup/execute/verify structure.

Resolves: #102117
Related: #101601
Releases: main, 12.4
Change-Id: Iaa6cee9893d41cb95e20cda80e03f044d52d82cd
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81374
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
TYPO3IncTeam pushed a commit to TYPO3-CMS/form that referenced this issue Oct 15, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow best practices and
avoid deprecation warnings later with PHPUnit 11.

We do this by creating dedicated fixture subclasses of the affected
abstract classes.

This change also cleans up the affected test to better match the
setup/execute/verify structure.

Resolves: #102117
Related: #101601
Releases: main, 12.4
Change-Id: Iaa6cee9893d41cb95e20cda80e03f044d52d82cd
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81350
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
TYPO3IncTeam pushed a commit to TYPO3-CMS/form that referenced this issue Oct 15, 2023
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow best practices and
avoid deprecation warnings later with PHPUnit 11.

We do this by creating dedicated fixture subclasses of the affected
abstract classes.

This change also cleans up the affected test to better match the
setup/execute/verify structure.

Resolves: #102117
Related: #101601
Releases: main, 12.4
Change-Id: Iaa6cee9893d41cb95e20cda80e03f044d52d82cd
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81374
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
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
xabbuh added a commit to symfony/symfony that referenced this issue May 15, 2024
…aubois)

This PR was merged into the 5.4 branch.

Discussion
----------

Remove calls to `getMockForAbstractClass()`

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Issues        | -
| License       | MIT

This method is deprecated (see sebastianbergmann/phpunit#5241), and must be replaced where used.

Commits
-------

a1843f3 Remove calls to `getMockForAbstractClass()`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/test-doubles Stubs and Mock Objects type/deprecation Something will be/is deprecated
Projects
None yet
Development

No branches or pull requests

1 participant