Problem/Motivation

The following code snippet does not fail a test on PHP 7:

$mock = $this->prophesize(\Drupal\Core\Mail\MailManagerInterface::class);
$mock->mail(\Prophecy\Argument::any())->shouldNotBeCalled();
$mail = $mail->reveal();
$mail->mail('system', 'action_send_email', 'admin@example.com', 'en');

We identified the bug in PHPUnit_Framework_TestCase::verifyMockObjects(), but it is fixed on the latest phpunit 4 version.

Proposed resolution

Upgrade phpunit to the latest phpunit 4 version to have reliable mocking expectations on PHP 7.
composer update phpunit/phpunit should do it.

Remaining tasks

Patch.

User interface changes

None.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#2 phpunit-update-2808497-2.patch1.74 KBklausi

Comments

klausi created an issue. See original summary.

klausi’s picture

Status: Active » Needs review
StatusFileSize
new1.74 KB

Patch.

I think we should not test this in Drupal because it is clearly an upstream bug and already covered by their tests. No need to duplicate that.

klausi’s picture

Issue tags: +Dublin2016
alexpott’s picture

Priority: Major » Critical
Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Issue tags: +rc eligible

I discovered this bug and was super confused. I think this is a critical bug because tests not actually testing what you think is being tested is super dangerous.

Also we have a policy to try to ensure that our dependencies are updated before minor release so I think this is rc eligible too.

alexpott’s picture

alexpott’s picture

  • catch committed 98e6f46 on 8.3.x
    Issue #2808497 by klausi, alexpott: Prophecy mocking broken on PHP 7...

  • catch committed a8f8e67 on 8.2.x
    Issue #2808497 by klausi, alexpott: Prophecy mocking broken on PHP 7...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.3.x and cherry-picked to 8.2.x. Thanks!

wim leers’s picture

I discovered this bug and was super confused. I think this is a critical bug because tests not actually testing what you think is being tested is super dangerous.

+1

I have no idea how you even tracked this down! klausi++

klausi’s picture

all credit to alexpott, I only contributed confused facial expressions.

wim leers’s picture

all credit to alexpott, I only contributed confused facial expressions.

:D :D :D :D

BEST CONTRIBUTION TYPE EVER

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.