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

GetMockBuilderGetMockToCreateMockRector breaks test code #86

Closed
kenjis opened this issue Jun 24, 2022 · 5 comments
Closed

GetMockBuilderGetMockToCreateMockRector breaks test code #86

kenjis opened this issue Jun 24, 2022 · 5 comments

Comments

@kenjis
Copy link

kenjis commented Jun 24, 2022

1) tests/system/Email/EmailTest.php:138

    ---------- begin diff ----------
@@ @@

     public function testDestructDoesNotThrowException()
     {
-        $email = $this->getMockBuilder(Email::class)
-            ->disableOriginalConstructor()
-            ->onlyMethods(['sendCommand'])
-            ->getMock();
+        $email = $this->createMock(Email::class);
         $email->method('sendCommand')
             ->willThrowException(new ErrorException('SMTP Error.'));
    ----------- end diff -----------

Applied rules:
 * GetMockBuilderGetMockToCreateMockRector (https://github.com/lmc-eu/steward/pull/187/files#diff-c7e8c65e59b8b4ff8b54325814d4ba55L80)

But when I run the test, I got the error:

$ vendor/bin/phpunit tests/system/Email/EmailTest.php
PHPUnit 9.5.21 #StandWithUkraine

Runtime:       PHP 8.0.20
Configuration: .../CodeIgniter4/phpunit.xml

........E                                                           9 / 9 (100%)E                                                           9 / 9 (100%)

Time: 00:00.358, Memory: 14.00 MB

There was 1 error:

1) CodeIgniter\Email\EmailTest::testDestructDoesNotThrowException
PHPUnit\Framework\MockObject\MethodNameNotConfiguredException: Method name is not configured

ERRORS!
Tests: 9, Assertions: 20, Errors: 1.
@samsonasik
Copy link
Member

it seems there is test that remove onlyMethods for it:

and it registered at:

@kenjis is the error happen when ->method('sendCommand') is called?

@kenjis
Copy link
Author

kenjis commented Jun 24, 2022

Yes, I think so.

@TomasVotruba
Copy link
Member

Let's continue discussion in one place to keep it simple: #87 (comment)

@SantosSi
Copy link

SantosSi commented Aug 20, 2022

Find what could explain the misbehavior in my comment in #87.

@samsonasik
Copy link
Member

Resolved at #205

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants