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

Migrate test double code generator tests from PHPT #5476

Open
sebastianbergmann opened this issue Aug 18, 2023 · 2 comments
Open

Migrate test double code generator tests from PHPT #5476

sebastianbergmann opened this issue Aug 18, 2023 · 2 comments
Assignees
Labels
feature/test-doubles Stubs and Mock Objects type/tests Tests! Yes, PHPUnit, too, needs tests.

Comments

@sebastianbergmann
Copy link
Owner

We currently have quite a few slow PHPT tests for the test double code generator.

These tests should be migrated from PHPT to regular PHPUnit tests.

This will reduce the time needed to run PHPUnit's test suite and lead to tests that are oblivious to changes in the generated code that do not affect behaviour.

@sebastianbergmann sebastianbergmann added the type/tests Tests! Yes, PHPUnit, too, needs tests. label Aug 18, 2023
@marac19901990
Copy link
Contributor

@sebastianbergmann Just to check so I don't waste time, is this what you had in mind?
If you give me the heads up, I'll move all the phpt files from the generator folder to simple unit tests.

    public function testReturnTypeDeclarationsVoid()
    {
        $generator = new PHPUnit\Framework\MockObject\Generator\Generator;
        $mock = $generator->generate(
            'Foo2',
            true,
            [],
            'MockFoo'
        );
        $mock = $this->instantiate($mock->generate());

        $mock->expects($this->once())->method('bar')->willReturnCallback(function(string $baz): void {
            $this->assertSame('test_foo2', $baz);
        });

        $this->assertNull($mock->bar('test_foo2'));
        $this->assertInstanceOf(Foo2::class, $mock);
        $this->assertInstanceOf(MockObjectInternal::class, $mock);
    }

@sebastianbergmann sebastianbergmann self-assigned this Jan 18, 2024
@sebastianbergmann sebastianbergmann added the feature/test-doubles Stubs and Mock Objects label Jan 18, 2024
@sebastianbergmann
Copy link
Owner Author

Thank you, Marko, for offering to help. But I do not know yet what the right test strategy here is. I also do not know when I will find the time to think about this. Sorry.

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/tests Tests! Yes, PHPUnit, too, needs tests.
Projects
None yet
Development

No branches or pull requests

2 participants