diff --git a/.gitignore b/.gitignore
index 3a9875b..bb4c194 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,5 @@
/vendor/
composer.lock
+
+# Test specific ignores
+tests/resources/cache
\ No newline at end of file
diff --git a/bin/goaop-zf2-warmup b/bin/goaop-zf2-warmup
old mode 100644
new mode 100755
index a128a14..cd1356d
--- a/bin/goaop-zf2-warmup
+++ b/bin/goaop-zf2-warmup
@@ -2,7 +2,7 @@
add(new Zf2WarmupCommand());
+$app->add(new WarmupCommand());
$app->run();
diff --git a/composer.json b/composer.json
index ac90253..09a4377 100644
--- a/composer.json
+++ b/composer.json
@@ -6,7 +6,7 @@
"license": "MIT",
"require": {
"goaop/framework": "^1.0|^2.0",
- "zendframework/zend-modulemanager": "^2.0 | ^3.0"
+ "zendframework/zend-modulemanager": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "^5.0 | ^6.0",
@@ -15,7 +15,11 @@
"zendframework/zend-serializer": "^2.0",
"zendframework/zend-log": "^2.0",
"zendframework/zend-i18n": "^2.0",
- "zendframework/zend-console": "^2.0"
+ "zendframework/zend-console": "^2.0",
+ "symfony/console": "^3.0 | ^4.0"
+ },
+ "suggest": {
+ "symfony/console": "Required to use goaop console warmup"
},
"authors": [
{
@@ -30,12 +34,12 @@
"bin": ["bin/goaop-zf2-warmup"],
"autoload": {
"psr-4": {
- "Go\\ZF2\\GoAopModule\\" : "src/"
+ "Go\\Zend\\Framework\\" : "src/"
}
},
"autoload-dev": {
"psr-4": {
- "Go\\ZF2\\GoAopModule\\Tests\\" : "tests/"
+ "Go\\Zend\\Framework\\Tests\\" : "tests/"
}
}
}
diff --git a/config/module.config.php b/config/module.config.php
index 01d37a1..ac20fa5 100644
--- a/config/module.config.php
+++ b/config/module.config.php
@@ -9,8 +9,8 @@
use Go\Core\AspectContainer;
use Go\Core\AspectKernel;
use Go\Core\GoAspectContainer;
-use Go\ZF2\GoAopModule\Factory\AspectContainerFactory;
-use Go\ZF2\GoAopModule\Factory\AspectKernelFactory;
+use Go\Zend\Framework\Factory\AspectContainerFactory;
+use Go\Zend\Framework\Factory\AspectKernelFactory;
$basicDirectory = defined('APPLICATION_PATH') ? APPLICATION_PATH : __DIR__ . '/../../../..';
@@ -94,12 +94,14 @@
];
return [
- 'goaop_module' => $moduleConfig,
+ \Go\Zend\Framework\Module::CONFIG_KEY => $moduleConfig,
+
'service_manager' => [
'factories' => [
AspectKernel::class => AspectKernelFactory::class,
AspectContainer::class => AspectContainerFactory::class,
]
],
- 'goaop_aspect' => []
+
+ \Go\Zend\Framework\Module::ASPECT_CONFIG_KEY => []
];
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 32383b4..6e06de2 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -13,6 +13,7 @@
./tests/Integration/
./tests/Unit/
+ ./tests/Functional/
diff --git a/src/Console/Warmup/Zf2WarmupCommand.php b/src/Console/Command/WarmupCommand.php
similarity index 98%
rename from src/Console/Warmup/Zf2WarmupCommand.php
rename to src/Console/Command/WarmupCommand.php
index b35be8b..2d97da5 100644
--- a/src/Console/Warmup/Zf2WarmupCommand.php
+++ b/src/Console/Command/WarmupCommand.php
@@ -1,6 +1,6 @@
init($serviceLocator->get('config')['goaop_module']);
+ $aspectKernel = AspectKernel::getInstance();
+ $aspectKernel->init($serviceLocator->get('config')[Module::CONFIG_KEY]);
return $aspectKernel;
}
diff --git a/src/Kernel/AspectZf2Kernel.php b/src/Kernel/AspectKernel.php
similarity index 79%
rename from src/Kernel/AspectZf2Kernel.php
rename to src/Kernel/AspectKernel.php
index 9909668..c9724b5 100644
--- a/src/Kernel/AspectZf2Kernel.php
+++ b/src/Kernel/AspectKernel.php
@@ -8,16 +8,15 @@
* with this source code in the file LICENSE.
*/
-namespace Go\ZF2\GoAopModule\Kernel;
+namespace Go\Zend\Framework\Kernel;
use Go\Core\AspectContainer;
-use Go\Core\AspectKernel;
/**
- * ZF2 aspect kernel class
+ * Aspect kernel class
*/
-class AspectZf2Kernel extends AspectKernel
+class AspectKernel extends \Go\Core\AspectKernel
{
/**
diff --git a/src/Module.php b/src/Module.php
index f6a6594..3e3c36c 100644
--- a/src/Module.php
+++ b/src/Module.php
@@ -8,7 +8,7 @@
* with this source code in the file LICENSE.
*/
-namespace Go\ZF2\GoAopModule;
+namespace Go\Zend\Framework;
use Go\Core\AspectContainer;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
@@ -17,10 +17,13 @@
use Zend\ModuleManager\ModuleManagerInterface;
/**
- * ZF2 Module for registration of Go! AOP Framework
+ * Module for registration of Go! AOP Framework
*/
class Module implements ConfigProviderInterface, InitProviderInterface
{
+ const CONFIG_KEY = 'goaop_module';
+ const ASPECT_CONFIG_KEY = 'goaop_aspect';
+
/**
* @inheritDoc
*/
@@ -44,7 +47,8 @@ public function initializeAspects(ModuleEvent $e)
/** @var AspectContainer $aspectContainer */
$aspectContainer = $serviceManager->get(AspectContainer::class);
$config = $serviceManager->get('config');
- $listOfAspects = $config['goaop_aspect'];
+ $listOfAspects = $config[self::ASPECT_CONFIG_KEY];
+
foreach ($listOfAspects as $aspectService) {
$aspect = $serviceManager->get($aspectService);
$aspectContainer->registerAspect($aspect);
diff --git a/tests/Advice/TestAdvice.php b/tests/Advice/TestAdvice.php
new file mode 100644
index 0000000..614bcb6
--- /dev/null
+++ b/tests/Advice/TestAdvice.php
@@ -0,0 +1,13 @@
+get*(*))")
+ */
+ public function aspectAdvice(MethodInvocation $invocation)
+ {
+ }
}
\ No newline at end of file
diff --git a/tests/Functional/WarmupTest.php b/tests/Functional/WarmupTest.php
new file mode 100644
index 0000000..de0db7e
--- /dev/null
+++ b/tests/Functional/WarmupTest.php
@@ -0,0 +1,45 @@
+prophesize(InputInterface::class);
+ $input->bind(Argument::any())->willReturn();
+ $input->isInteractive()->willReturn(false);
+ $input->hasArgument(Argument::any())->willReturn(false);
+ $input->validate()->willReturn();
+
+ $input->getArgument('applicationConfig')
+ ->willReturn(__DIR__ . '/../resources/application_config.php');
+
+ $output = $this->getMockBuilder(OutputInterface::class)
+ ->setMethods(['writeln'])
+ ->getMockForAbstractClass();
+
+ $output->expects($this->at(1))
+ ->method('writeln')
+ ->with('Total 1 files to process.');
+
+ $command = new WarmupCommand();
+ $command->run($input->reveal(), $output);
+ }
+}
\ No newline at end of file
diff --git a/tests/Integration/ModuleTest.php b/tests/Integration/ModuleTest.php
index 619d5e1..d40f82a 100644
--- a/tests/Integration/ModuleTest.php
+++ b/tests/Integration/ModuleTest.php
@@ -1,15 +1,15 @@
prophesize(ServiceLocatorInterface::class);
$serviceLocator->get('config')
- ->willReturn(['goaop_module' => require __DIR__ . '/../../resources/goaop_module.php'])
+ ->willReturn([Module::CONFIG_KEY => require __DIR__ . '/../../resources/goaop_module.php'])
->shouldBeCalled();
$factory = new AspectKernelFactory();
@@ -40,7 +41,7 @@ public function itCreatesKernelOnCreateService()
{
$serviceLocator = $this->prophesize(ServiceLocatorInterface::class);
$serviceLocator->get('config')
- ->willReturn(['goaop_module' => require __DIR__ . '/../../resources/goaop_module.php'])
+ ->willReturn([Module::CONFIG_KEY => require __DIR__ . '/../../resources/goaop_module.php'])
->shouldBeCalled();
$factory = new AspectKernelFactory();
diff --git a/tests/Unit/ModuleTest.php b/tests/Unit/ModuleTest.php
index 9d3699f..4b47128 100644
--- a/tests/Unit/ModuleTest.php
+++ b/tests/Unit/ModuleTest.php
@@ -1,10 +1,10 @@
willReturn($aspectContainer->reveal())
->shouldBeCalled();
$serviceManager->get('config')
- ->willReturn(['goaop_aspect' => ['testAspect']])
+ ->willReturn([Module::ASPECT_CONFIG_KEY => ['testAspect']])
->shouldBeCalled();
$serviceManager->get('testAspect')
->willReturn($aspect)
diff --git a/tests/resources/application_config.php b/tests/resources/application_config.php
old mode 100755
new mode 100644
index 57184dd..c4f3efe
--- a/tests/resources/application_config.php
+++ b/tests/resources/application_config.php
@@ -1,7 +1,7 @@
[
__DIR__ . '/../../vendor',
],
+
'config_glob_paths' => [
__DIR__ . '/{{,*.}global,{,*.}local}.php',
],
- ],
+ ]
];
diff --git a/tests/resources/global.php b/tests/resources/global.php
index 0ab315d..edd8ca5 100644
--- a/tests/resources/global.php
+++ b/tests/resources/global.php
@@ -1,13 +1,15 @@
require 'goaop_module.php',
- 'goaop_aspect' => [
- \Go\ZF2\GoAopModule\Tests\Aspect\TestAspect::class,
+ \Go\Zend\Framework\Module::CONFIG_KEY => require 'goaop_module.php',
+
+ \Go\Zend\Framework\Module::ASPECT_CONFIG_KEY => [
+ \Go\Zend\Framework\Tests\Aspect\TestAspect::class,
],
+
'service_manager' => [
'factories' => [
- \Go\ZF2\GoAopModule\Tests\Aspect\TestAspect::class => \Zend\ServiceManager\Factory\InvokableFactory::class,
+ \Go\Zend\Framework\Tests\Aspect\TestAspect::class => \Zend\ServiceManager\Factory\InvokableFactory::class,
],
],
];
\ No newline at end of file
diff --git a/tests/resources/goaop_module.php b/tests/resources/goaop_module.php
index 2e74a47..c41c485 100644
--- a/tests/resources/goaop_module.php
+++ b/tests/resources/goaop_module.php
@@ -2,11 +2,13 @@
return [
'debug' => true,
- 'appDir' => __DIR__,
- 'cacheDir' => __DIR__,
+ 'appDir' => __DIR__ . '/../',
+ 'cacheDir' => __DIR__ . '/cache',
'cacheFileMode' => 0770 & ~umask(),
'features' => 0,
- 'includePaths' => [],
+ 'includePaths' => [
+ __DIR__ . '/../Advice'
+ ],
'excludePaths' => [],
'containerClass' => \Go\Core\GoAspectContainer::class,
];