Skip to content

Namespace change #11

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

Merged
merged 5 commits into from
Dec 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/vendor/
composer.lock

# Test specific ignores
tests/resources/cache
5 changes: 3 additions & 2 deletions bin/goaop-zf2-warmup
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?php

use Go\Core\AspectKernel;
use Go\ZF2\GoAopModule\Console\Warmup\Zf2WarmupCommand;
use Go\Zend\Framework\Console\Command\WarmupCommand;
use Symfony\Component\Console\Application;


Expand All @@ -26,7 +26,8 @@ if (!class_exists('Symfony\Component\Console\Application')) {
);
}


$app = new Application('Go! AOP', AspectKernel::VERSION);
$app->add(new Zf2WarmupCommand());
$app->add(new WarmupCommand());
$app->run();

12 changes: 8 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": [
{
Expand All @@ -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/"
}
}
}
10 changes: 6 additions & 4 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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__ . '/../../../..';

Expand Down Expand Up @@ -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 => []
];
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<testsuite name="Go! AOP ZF Module Test Suite">
<directory>./tests/Integration/</directory>
<directory>./tests/Unit/</directory>
<directory>./tests/Functional/</directory>
</testsuite>
</testsuites>
<filter>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Go\ZF2\GoAopModule\Console\Warmup;
namespace Go\Zend\Framework\Console\Command;

use Go\Core\AspectKernel;
use Go\Instrument\ClassLoading\SourceTransformingLoader;
Expand All @@ -11,7 +11,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class Zf2WarmupCommand extends Command
class WarmupCommand extends Command
{
/**
* {@inheritDoc}
Expand Down
2 changes: 1 addition & 1 deletion src/Factory/AspectContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* with this source code in the file LICENSE.
*/

namespace Go\ZF2\GoAopModule\Factory;
namespace Go\Zend\Framework\Factory;

use Go\Core\AspectKernel;
use Interop\Container\ContainerInterface;
Expand Down
9 changes: 5 additions & 4 deletions src/Factory/AspectKernelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
* with this source code in the file LICENSE.
*/

namespace Go\ZF2\GoAopModule\Factory;
namespace Go\Zend\Framework\Factory;

use Go\ZF2\GoAopModule\Kernel\AspectZf2Kernel;
use Go\Zend\Framework\Kernel\AspectKernel;
use Go\Zend\Framework\Module;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
Expand Down Expand Up @@ -43,8 +44,8 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$aspectKernel = AspectZf2Kernel::getInstance();
$aspectKernel->init($serviceLocator->get('config')['goaop_module']);
$aspectKernel = AspectKernel::getInstance();
$aspectKernel->init($serviceLocator->get('config')[Module::CONFIG_KEY]);

return $aspectKernel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

/**
Expand Down
10 changes: 7 additions & 3 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
*/
Expand All @@ -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);
Expand Down
13 changes: 13 additions & 0 deletions tests/Advice/TestAdvice.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Go\Zend\Framework\Tests\Advice;

/**
* @package Go\Zend\Framework\Tests\Advice
*/
class TestAdvice
{
public function getTest($parameter)
{
}
}
14 changes: 11 additions & 3 deletions tests/Aspect/TestAspect.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
<?php

namespace Go\ZF2\GoAopModule\Tests\Aspect;
namespace Go\Zend\Framework\Tests\Aspect;

use Go\Aop\Aspect;
use Go\Aop\Intercept\MethodInvocation;
use Go\Lang\Annotation\Around;

/**
* @package Go\ZF2\GoAopModule\Tests\Aspect
* @package Go\Zend\Framework\Tests\Aspect
*/
class TestAspect implements Aspect
{

/**
* @param MethodInvocation $invocation
* @Around("execution(public Go\Zend\Framework\Tests\Advice\TestAdvice->get*(*))")
*/
public function aspectAdvice(MethodInvocation $invocation)
{
}
}
45 changes: 45 additions & 0 deletions tests/Functional/WarmupTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Go\Zend\Framework\Tests\Functional;

use Go\Zend\Framework\Console\Command\WarmupCommand;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\Input;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
* @package Go\Zend\Framework\Tests\Functional
*/
class WarmupTest extends TestCase
{
/**
* @test
*/
public function itShouldFindAdviceAccordingToConfig()
{
$input = $this->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 <info>1</info> files to process.');

$command = new WarmupCommand();
$command->run($input->reveal(), $output);
}
}
6 changes: 3 additions & 3 deletions tests/Integration/ModuleTest.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php

namespace Go\ZF2\GoAopModule\Tests\Integration;
namespace Go\Zend\Framework\Tests\Integration;

use Go\Core\AspectContainer;
use Go\Core\GoAspectContainer;
use Go\ZF2\GoAopModule\Tests\Aspect\TestAspect;
use Go\Zend\Framework\Tests\Aspect\TestAspect;
use PHPUnit\Framework\TestCase;
use Zend\Mvc\Application;

/**
* @package Go\ZF2\GoAopModule\Tests\Integration
* @package Go\Zend\Framework\Tests\Integration
*/
class ModuleTest extends TestCase
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Factory/AspectContainerFactoryTest.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php

namespace Go\ZF2\GoAopModule\Tests\Unit\Factory;
namespace Go\Zend\Framework\Tests\Unit\Factory;

use Go\Core\AspectContainer;
use Go\Core\AspectKernel;
use Go\ZF2\GoAopModule\Factory\AspectContainerFactory;
use Go\Zend\Framework\Factory\AspectContainerFactory;
use PHPUnit\Framework\TestCase;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
* @package Go\ZF2\GoAopModule\Tests\Unit\Factory
* @package Go\Zend\Framework\Tests\Unit\Factory
*/
class AspectContainerFactoryTest extends TestCase
{
Expand Down
11 changes: 6 additions & 5 deletions tests/Unit/Factory/AspectKernelFactoryTest.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?php

namespace Go\ZF2\GoAopModule\Tests\Unit\Factory;
namespace Go\Zend\Framework\Tests\Unit\Factory;

use Go\Core\AspectKernel;
use Go\ZF2\GoAopModule\Factory\AspectKernelFactory;
use Go\Zend\Framework\Factory\AspectKernelFactory;
use Go\Zend\Framework\Module;
use PHPUnit\Framework\TestCase;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
* @package Go\ZF2\GoAopModule\Tests\Unit\Factory
* @package Go\Zend\Framework\Tests\Unit\Factory
*/
class AspectKernelFactoryTest extends TestCase
{
Expand All @@ -19,7 +20,7 @@ public function itCreatesKernelOnInvoke()
{
$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();
Expand All @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/ModuleTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Go\ZF2\GoAopModule\Tests\Unit;
namespace Go\Zend\Framework\Tests\Unit;

use Go\Aop\Aspect;
use Go\Core\AspectContainer;
use Go\ZF2\GoAopModule\Module;
use Go\Zend\Framework\Module;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Zend\EventManager\EventManagerInterface;
Expand All @@ -13,7 +13,7 @@
use Zend\ServiceManager\ServiceManager;

/**
* @package Go\ZF2\GoAopModule\Tests\Unit
* @package Go\Zend\Framework\Tests\Unit
*/
class ModuleTest extends TestCase
{
Expand Down Expand Up @@ -66,7 +66,7 @@ public function itRegisterAspectsOnInitializeAspects()
->willReturn($aspectContainer->reveal())
->shouldBeCalled();
$serviceManager->get('config')
->willReturn(['goaop_aspect' => ['testAspect']])
->willReturn([Module::ASPECT_CONFIG_KEY => ['testAspect']])
->shouldBeCalled();
$serviceManager->get('testAspect')
->willReturn($aspect)
Expand Down
Loading