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

[DX][Internal] Init ApiTestCase #972

Open
wants to merge 1 commit into
base: 1.13
Choose a base branch
from

Conversation

loic425
Copy link
Member

@loic425 loic425 commented Jan 15, 2025

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Related tickets
License MIT

@loic425 loic425 marked this pull request as draft January 15, 2025 17:10
@loic425 loic425 force-pushed the api-test-case branch 7 times, most recently from 59212f9 to 19bf967 Compare January 16, 2025 10:59
@loic425 loic425 changed the title Init ApiTestCase [DX][Internal] Init ApiTestCase Jan 16, 2025
@loic425 loic425 added the DX Issues and PRs aimed at improving Developer eXperience. label Jan 16, 2025
@loic425 loic425 force-pushed the api-test-case branch 4 times, most recently from 7500a98 to 0c6d68d Compare January 22, 2025 08:02
@loic425 loic425 marked this pull request as ready for review January 22, 2025 08:04
@loic425 loic425 added the Maintenance Configurations, READMEs, releases, etc. label Jan 22, 2025
protected Matcher $matcher;

#[Before]
protected function _createClient(): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does _ function prefix passes CS checks?

Copy link
Member Author

@loic425 loic425 Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's a common way in this kind of trait.
https://github.com/zenstruck/foundry/blob/2.x/src/Test/ResetDatabase.php#L29

We are in the test application. For now I do not plan to make a small lib with that kind of traits.

I'd like to remove my PurgeDatabaseTrait to be honest. I have some issues with ResetDatabase (from Foundry package) sometimes, but I plan to remove this PurgeDatabaseTrait at some point.

tests/Application/src/Tests/Controller/BlogPostApiTest.php Outdated Show resolved Hide resolved
tests/Application/src/Tests/Responses/.gitignore Outdated Show resolved Hide resolved
tests/PurgeDatabaseTrait.php Show resolved Hide resolved
@loic425 loic425 force-pushed the api-test-case branch 2 times, most recently from 9056331 to 818060b Compare January 22, 2025 15:02
}

#[Before]
protected static function _createMatcher(): Matcher
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this change possible, the same as with createClient/setupClient change.

Suggested change
protected static function _createMatcher(): Matcher
protected static function createMatcher(): Matcher
protected static function setupMatcher(): Matcher

$this->assertResponseCode($response, Response::HTTP_NO_CONTENT);

$this->assertResponseIsSuccessful();
$this->assertResponseStatusCodeSame(Response::HTTP_NO_CONTENT);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test doesn't appear to be checking if PUT action actually changed comic book data.

$this->assertResponseCode($response, Response::HTTP_NO_CONTENT);

$this->assertResponseIsSuccessful();
$this->assertResponseStatusCodeSame(Response::HTTP_NO_CONTENT);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's still actual.

        $deletedComicBook = $this->getContainer()->get('app.repository.comic_book')->find($comicBookId);
        $this->assertNull($deletedComicBook);

$this->assertResponseCode($response, Response::HTTP_NO_CONTENT);

$this->assertResponseIsSuccessful();
$this->assertResponseStatusCodeSame(Response::HTTP_NO_CONTENT);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test doesn't appear to be checking if PUT action actually happened.

{
return $this->matcherFactory->createMatcher(new VoidBacktrace());
$this->assertResponseIsSuccessful();
$this->assertResponseStatusCodeSame(Response::HTTP_NO_CONTENT);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test doesn't appear to be checking if subscription was actually removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Issues and PRs aimed at improving Developer eXperience. Maintenance Configurations, READMEs, releases, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants