-
Notifications
You must be signed in to change notification settings - Fork 25
Added new tool - expressive-module (#8 and #9) #12
Added new tool - expressive-module (#8 and #9) #12
Conversation
Syntax is perfect - exactly what I'd expect! Looking forward to reviewing the final iterations! |
@weierophinney It's ready for review, tests are failing but some of them are fixed in #10, so it should be merged first. Of course it needs also |
@webimpress I've tagged zend-component-installer 0.7.0 at this time, and merged #10. As for messages, how about:
|
Tool provide following commands: - "create" - create skeleton of the expressive module and register it - "register" - register module in configuration and composer autoloading - "deregister" - deregister module from configuration and composer autoloading Tool accept following arguments: - "--composer|-c" path to composer binary - "--modules-path|-p" - path to modules directory
Eliminated dependency of composer/composer package. Now to inject/remove methods we don't need to pass IOInterface.
Redirect stderr to stdout 2>&1 Works also on Windows.
Added catching RuntimeException from zf-composer-autoloading and throwing module RuntimeException. Now we have then consistent interface, and process method throws only exception from the module. Updated PHPDocs to reflect these changes.
Now commands from zfcampus/zf-composer-autoloading are invoked via "process" method instead of "__invoke". Also disabled moving module class for the module on enabling autoloading.
I've notice issue with constant and Mockery. If we use Mockery to mock class, than we can't access to the constants. This change uses constants from another class, so we have access on mocking ConfigAggregatorInjector.
- zendframework/zend-component-installer ^0.7 - zf-composer-autoloading ^2.0
@weierophinney Rebased, used latest stable dependencies and added success messages as suggested. Ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fantastic, @webimpress ! There are a few minor changes I've suggested, and one larger one that, honestly, I can go either way on (whether or not to memorize $modulePath
). Let me know how you want to proceed on that, and I can merge.
composer.json
Outdated
@@ -40,7 +44,8 @@ | |||
"bin": [ | |||
"bin/expressive-migrate-original-messages", | |||
"bin/expressive-pipeline-from-config", | |||
"bin/expressive-scan-for-error-middleware" | |||
"bin/expressive-scan-for-error-middleware", | |||
"bin/expressive-module" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be alphabetized.
/** | ||
* The configuration provider for the %1$s module | ||
* | ||
* @see https://docs.zendframework.com/zend-component-installer/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice touch! Linking to the documentation will definitely assist new developers.
src/Module/Command/Create.php
Outdated
*/ | ||
private function createDirectoryStructure($moduleName) | ||
{ | ||
if (file_exists($this->modulePath)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering that $modulePath
is calculated by process()
, perhaps it should be passed as an argument to each of this method and createConfigProvider()
, instead of memoized as a property? That would be one less state for the instance to track.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed - property removed, now method has two parameters.
src/Module/Help.php
Outdated
<info>Commands:</info> | ||
|
||
<info>help</info> Display this help/usage message | ||
<info>create</info> Create skeleton of the expressive module and register it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/skeleton of/source tree for/
src/Module/Help.php
Outdated
|
||
<info>help</info> Display this help/usage message | ||
<info>create</info> Create skeleton of the expressive module and register it | ||
<info>register</info> Register module in configuration and composer autoloading |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Register module in application configuration, and enable autoloading of module via composer."
src/Module/Help.php
Outdated
<info>help</info> Display this help/usage message | ||
<info>create</info> Create skeleton of the expressive module and register it | ||
<info>register</info> Register module in configuration and composer autoloading | ||
<info>deregister</info> Deregister module from configuration and composer autoloading |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Deregister module from application configuration, and disable autoloading of module via composer."
{ | ||
$baseModulePath = sprintf('%s/my-modules/MyApp', $this->dir->url()); | ||
|
||
$mkdir = $this->getFunctionMock('Zend\Expressive\Tooling\Module\Command', 'mkdir'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not aware of getFunctionMock()
! Awesome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please not this is not from PHPUnit but from php-mock
library. Integration with PHPUnit is via php-mock/php-mock-phpunit
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, okay - did you add that dependency, or does PHPUnit depend on it itself? Either way, it's a nice library to know about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I added:
"php-mock/php-mock-phpunit": "^2.0 || ^1.1.2",
There is also integration library with prophecy and mocker.
https://github.com/php-mock
I've chosen integration with PHPUnit as this is the main testing library. I know that many mocking we are doing recently using prophecy, so maybe better choice will be php-mock-prophecy
?
Here is the library with the main functionality:
https://github.com/php-mock/php-mock
namespace ZendTest\Expressive\Tooling\Module\Command; | ||
|
||
use Mockery; | ||
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this what allows you to not need to specify @runInSeparateProcess
for tests that overload classes via Mockery?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... this is recommended in Mockery documentation:
http://docs.mockery.io/en/latest/reference/phpunit_integration.html
I was trying to remove @runInSeparateProcess
but some tests on some versions (php versions/dependencies) were failing. As you can note in some tests we still have this annotation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've somehow missed that documentation page previously, so, again, a nice thing to know about!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look perfect! Thanks, @webimpress !
New tool
vendor/bin/expressive-module
Tool provide following commands:
create
- create skeleton of the expressive module and register itregister
- register module in configuration and composer autoloadingderegister
- deregister module from configuration and composer autoloadingTool accept following arguments:
--composer|-c
path to composer binary--modules-path|-p
- path to modules directoryTODO:
zfcampus/zf-composer-autoloading
as there is also registering module in composer.json - done in [v2.0] [BC Break] Rewrite library with ConsoleHelper + tests zfcampus/zf-composer-autoloading#8zendframework/zend-component-installer
then we can have here less dependencies - now because we are using this library we require herecomposer/composer
- done in [BC Break] Refactor and injector interface changes zend-component-installer#34.Resolves #8 and #9