Skip to content

Latest commit

 

History

History
77 lines (60 loc) · 2.76 KB

6.md

File metadata and controls

77 lines (60 loc) · 2.76 KB

Console Command hello:bundles

Create a Symfony bundle, that defines a console command and allows other Symfony bundles in the application to provide their own code that should run whenever this command is executed.

Provide two sample bundles to demonstrate the work of this application.

Detailed Requirements

Using Symfony 5.3+ create a bundle called HelloCommandBundle. This bundle should provide a console command called hello:bundles

php app/console hello:bundles

Any other bundle installed in the same Symfony application should be able to add their own code for execution.

For the demonstration purposes create two bundles FooBundle and BarBundle.

FooBundle should provide the following code:

echo "Hello from Foo!";

BarBundle should provide the following code:

echo "Hi from Bar!";

Whenever a used runs php app/console hello:bundles, the following output should be produced:

Hello from Foo!
Hi from Bar!

NB: The number of bundles willing to greet a user is not known. There could be a dozen, or none. Not all of the installed bundles may be willing to do something when hello command is executed. Provide other bundles a way to register their code only if they want to.

Logging

Implement detailed logging, so that after execution of php app/console hello:bundles the application log file will contain the following records (with actual time obviously):

[2016-01-29 09:08:31] Starting the group greetings...
[2016-01-29 09:08:32] Is Foo polite and welcoming today?
[2016-01-29 09:08:32] Hello from Foo!
[2016-01-29 09:08:32] Is Bar polite and welcoming today?
[2016-01-29 09:08:32] Hi from Bar!
[2016-01-29 09:08:32] All greetings completed.

Tests

Create a functional test for the hello:bundles console command itself.

Create unit tests for all other code in the HelloBundle.

NB: FooBundle and BarBundle are just for the demo. You do not need to create any tests for them.

NB: Do not forget to write negative tests as well. A positive test checks if a function behaves as expected with its expected input. A negative test checks if a function behaves as expected when something goes wrong. An expected result in this case could be a thrown exception, or returned boolean false - as defined by the developer of the tested method.

Other Requirements

After the task is completed, provide a link to the repository on GitHub or BitBucket.