-
-
Notifications
You must be signed in to change notification settings - Fork 415
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
[make:entity] Fix error when API-Platform is installed. #881
Conversation
It'd be great to have a test to "cover" the error. However, the fact that the tests DO pass with this change (the |
Thank you Ryan. I tried the last days to get the tests running. Marbulk helped me a lot - because I never wrote tests before. Actually thats something I want to watch next on symfonycasts ;) . But I can't get the MakeEntityTest running. Hm. Are this the tests wich are currently broken - as u said before? Because when I run all tests of maker-bundle I can see that there are test succeeding. |
@weaverryan Any help for the new contributor from the maintainer? I think Symfony is all about contributors. |
Hm, I don't really see me as a contributer yet. I just found a bug and wrote a few lines to fix that. I also tried 3 days long to make those tests work. But I am completly new to testing. I also have a fulltime-job and for these 3 days of trying to make the tests work, I stopped working on my side projects. |
Tests fail seem unrelated to the PR. To trigger the actual bug, you should update or create a duplicate of it: File: https://github.com/symfony/maker-bundle/blob/main/tests/Maker/MakeEntityTest.php yield 'entity_new' => [MakerTestDetails::createTest(
$this->getMakerInstance(MakeEntity::class),
[
// entity class name
'User',
// add not additional fields
'',
])
->setFixtureFilesPath(__DIR__.'/../fixtures/MakeEntity')
->configureDatabase()
->updateSchemaAfterCommand(),
]; This test simulate the creation of a basic new Entity, without any fields. The wizard do not ask about Broadcasting or APiPlatform (because not simulated as installed). In this test: yield 'entity_new_api_resource' => [MakerTestDetails::createTest(
$this->getMakerInstance(MakeEntity::class),
[
// entity class name
'User',
// Mark the entity as an API Platform resource
'y',
// add not additional fields
'',
])
->addExtraDependencies('api')
->setFixtureFilesPath(__DIR__.'/../fixtures/MakeEntity')
->configureDatabase()
->updateSchemaAfterCommand()
->assert(function (string $output, string $directory) {
$this->assertFileExists($directory.'/src/Entity/User.php');
$content = file_get_contents($directory.'/src/Entity/User.php');
$this->assertStringContainsString('use ApiPlatform\Core\Annotation\ApiResource;', $content);
$this->assertStringContainsString(\PHP_VERSION_ID >= 80000 ? '#[ApiResource]' : '@ApiResource', $content);
}),
]; You have the same has before but with api platform, then in : yield 'entity_new_broadcast' => [MakerTestDetails::createTest(
$this->getMakerInstance(MakeEntity::class),
[
// entity class name
'User',
// Mark the entity as broadcasted
'y',
// add not additional fields
'',
])
->setRequiredPhpVersion(70200)
->addExtraDependencies('ux-turbo-mercure')
->setFixtureFilesPath(__DIR__.'/../fixtures/MakeEntity')
->configureDatabase()
->addReplacement(
'.env',
'https://127.0.0.1:8000/.well-known/mercure',
'http://127.0.0.1:1337/.well-known/mercure'
)
->updateSchemaAfterCommand()
->assert(function (string $output, string $directory) {
$this->assertFileExists($directory.'/src/Entity/User.php');
$content = file_get_contents($directory.'/src/Entity/User.php');
$this->assertStringContainsString('use Symfony\UX\Turbo\Attribute\Broadcast;', $content);
$this->assertStringContainsString(\PHP_VERSION_ID >= 80000 ? '#[Broadcast]' : '@Broadcast', $content);
}),
]; You create a basic one with a broadcast. In your case you want to create one new, simulating APiPlatform and Broadcat installed, but say "n" to their usage, it give something like: yield 'entity_new_with_api_and_broadcast_dependencies' => [MakerTestDetails::createTest(
$this->getMakerInstance(MakeEntity::class),
[
// entity class name
'User',
// Mark the entity as not an API Platform resource
'n',
// Mark the entity as not broadcasted
'n',
// add not additional fields
'',
])
->setRequiredPhpVersion(70200)
->addExtraDependencies('api')
->addExtraDependencies('ux-turbo-mercure')
->setFixtureFilesPath(__DIR__.'/../fixtures/MakeEntity')
->configureDatabase()
->updateSchemaAfterCommand(),
]; |
@mpiot if you’re willing and able, you could create another PR with the failing test. Then I could merge in both PR’s (your pr with the failing test and this fix). I’m just trying to see what we can do to move this forward given that we have several people trying to help! cheers! |
@weaverryan @MichaelBrauner just implement the missing test. I prefer help him to finish his PR (more interesting, I think). But if needed, I'll do that :) |
I did implement the test. I also tried it on my lokal project. It definetly works and fixes the bug. When the failing tests are not related to my PR, how can I then finish this PR? |
@MichaelBrauner Just need to wait a maintener approve the workflow running and approve your change (if not problems in code / tests) |
Awesome! Thanks to both @MichaelBrauner and @mpiot for getting this done :) |
This PR was merged into the 1.0-dev branch. Discussion ---------- [release] v1.33.0 Hi Makers! Insert clever words here ## [v1.33.0](https://github.com/symfony/maker-bundle/releases/tag/v1.33.0) *June 30th, 2021* ### Feature - [#895](#895) - [make:crud] send the proper HTTP status codes and use renderForm() when available - *`@dunglas`* - [#889](#889) - [make:user] Use password_hashers instead of encoders - *`@wouterj`* ### Bug Fix - [#913](#913) - [make:registration] conditionally generate verify email flash in template - *`@jrushlow`* - [#881](#881) - [make:entity] Fix error when API-Platform is installed. - *`@MichaelBrauner`* Diff: v1.32.0...v1.33.0 Happy making! Commits ------- aa1b721 [release] v1.33.0
I'll try to get the testsuite running. Then I will also write a test for that.