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

Remove getMock() #2194

Closed
sebastianbergmann opened this issue Jun 4, 2016 · 9 comments
Closed

Remove getMock() #2194

sebastianbergmann opened this issue Jun 4, 2016 · 9 comments
Assignees
Labels
type/backward-compatibility Something will be/is intentionally broken
Milestone

Comments

@sebastianbergmann
Copy link
Owner

Deprecated since PHPUnit 5.4.

@sebastianbergmann sebastianbergmann added feature-removal type/backward-compatibility Something will be/is intentionally broken labels Jun 4, 2016
@sebastianbergmann sebastianbergmann added this to the PHPUnit 6.0 milestone Jun 4, 2016
@sebastianbergmann sebastianbergmann self-assigned this Jun 4, 2016
@scaytrase
Copy link

As soon as 5.4 marked stable these lines (https://github.com/sebastianbergmann/phpunit/blob/5.4/src/Framework/TestCase.php#L1557) causes all project using stable phar or ~5.x as composer dependency fail as soon as the default option is to convert warning to exceptions is set to true (

)

Is it really neccessary to forcibly add warning on call?

The interesting moment that when using php7 - tests pass well, warning is ignored (or not raised?).

@sebastianbergmann
Copy link
Owner Author

@scaytrase $this->warnings[] has nothing to do with PHP warnings that are converted to exceptions.

@scaytrase
Copy link

I'm not really sure which option leads to this (this one has caused Symfony 2.7 fail two years ago then they started to trigger_error on any deprecated function), but anyway test run looks like following

$ phpunit --colors -c phpunit.xml
PHPUnit 5.4.6 by Sebastian Bergmann and contributors.
WWWWWWWWWWWWW                                                     13 / 13 (100%)
Time: 4.35 seconds, Memory: 22.00MB
There were 13 warnings:
1) Bankiru\Api\Tests\CollectionLoadingTest::testLazyCollections
PHPUnit_Framework_TestCase::getMock() is deprecated, use PHPUnit_Framework_TestCase::createMock() or PHPUnit_Framework_TestCase::getMockBuilder() instead

(13 equal warnings)

WARNINGS!
Tests: 13, Assertions: 112, Warnings: 13.

@sebastianbergmann
Copy link
Owner Author

As you can see in https://github.com/sebastianbergmann/phpunit/blob/5.4/src/Framework/TestCase.php#L936, these deprecation warnings are only generated when the test was successful, meaning that they do not hide test failures.

@scaytrase
Copy link

scaytrase commented Jun 17, 2016

The problem is on the other side. Previously successful test suite fails just because the enviorment (phpunit-stable) or dependency (~5.x) changes, so it looks like a BC-break at 5.4, not at 6.0

As far as I understand this does not comform well with semver or this project does not follow it strictly?

@sebastianbergmann
Copy link
Owner Author

A warning does not fail a test suite.

@scaytrase
Copy link

Yeah, you are fully correct, sorry. Cannot reproduce this on a sample test case. I'll try to search why travis' phpunit exits with 1 on 5.6

Thank you for clarifying

@scaytrase
Copy link

I've wrote a sample demonstration. PhpUnit exits with code 1 silently with travis, php 5.6.5 and phpunit 5.4.6

https://github.com/scaytrase/pu54-sample
https://travis-ci.org/scaytrase/pu54-sample/jobs/138289611

The php 5.6 build has the warning at the output:
https://travis-ci.org/scaytrase/pu54-sample/jobs/138289611
And the php 7.0 does not:
https://travis-ci.org/scaytrase/pu54-sample/jobs/138289612

Could you take a look? May be I do something wrong, but the sample is as simple as possible

@sebastianbergmann
Copy link
Owner Author

sebastianbergmann commented Jun 17, 2016

As you can see in the example below, a warning does not mark the test execution as a failure:

$ phpunit Test
PHPUnit 5.4.6 by Sebastian Bergmann and contributors.

W                                                                   1 / 1 (100%)

Time: 27 ms, Memory: 4.00MB

There was 1 warning:

1) Test::testOne
PHPUnit_Framework_TestCase::getMock() is deprecated, use PHPUnit_Framework_TestCase::createMock() or PHPUnit_Framework_TestCase::getMockBuilder() instead

WARNINGS!
Tests: 1, Assertions: 0, Warnings: 1.

$ echo $?                  
0

Exit code 0 means success.

Also note that this ticket is the wrong place to discuss your issue. This ticket is just a reminder to remove functionality for PHPUnit 6 that is deprecated in PHPUnit 5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/backward-compatibility Something will be/is intentionally broken
Projects
None yet
Development

No branches or pull requests

2 participants