Skip to content

Conversation

@weaverryan
Copy link
Member

This follows #807 - I played with it locally and had some minor tweaks :).

Cheers!

$command
->addArgument('name', InputArgument::OPTIONAL, 'The name of the test class (e.g. <fg=yellow>BlogPostTest</>)')
->addArgument('type', InputArgument::OPTIONAL, 'The type of test: '.implode(', ', $typesDesc))
->addArgument('name', InputArgument::OPTIONAL, 'The name of the test class (e.g. <fg=yellow>BlogPostTest</>)')
Copy link
Member Author

Choose a reason for hiding this comment

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

Once I played with this, I decided to reverse the arguments. It occurred to me that knowing the "type" as early as possible could help us. For example, I don't do it in this PR, but we could suggest different example filenames on the next question based on the type.

$io->warning([
'API Platform is required for this test type. Install it with',
'composer require api',
]);
Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately, the dependency system is called before the interactive step. So previously, no error or warning was shown. That's actually ok - I like showing a warning better than exploding with an error that they must stop and run the composer require command before starting the make:test command again.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed, seeing as we're not actually collecting a bunch of input that is dependent on Api Platform at this time - the warning makes sense..

'Choose a class name for your test, like:',
' * <fg=yellow>UtilTest</> (to create tests/UtilTest.php)',
' * <fg=yellow>Service\\UtilTest</> (to create tests/Service/UtilTest.php)',
' * <fg=yellow>\\App\Tests\\Service\\UtilTest</> (to create tests/Service/UtilTest.php)',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we (should we) suggest the class based on the test? e.g. if the type is UnitTest - we suggest 'App\\Tests\\UnitTests\\{NAME} or something along those lines?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about that too. Let's save it for a future PR... I don't think there is clear agreement on the directory conventions of these things. I personally don't sub-divide things into UnitTest or IntegrationTest directories, but I know that some people do this.

return;

case 'make:functional-test':
$input->setArgument('type', trait_exists(PantherTestCaseTrait::class) ? 'WebTestCase' : 'PantherTestCase');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just caught this - shouldn't this be asked? What if I want a WebTestCase to check the status codes of a couple routes but want PantherTestCase for browser based tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess even before this, if you used make:functional-test, we already looked to see if you had Panther available and then used it automatically. It's a minor thing, since this is deprecated. The new system of actually asking is much better. But I'll keep this the way it is now... which is the way it was before mostly.

@weaverryan weaverryan merged commit da4673f into symfony:main Feb 6, 2021
@weaverryan weaverryan deleted the make-test-tweaks branch February 6, 2021 21:22
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 this pull request may close these issues.

2 participants