-
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #337 from RunOpenCode/bugfix/335-fix-false-matchin…
…g-class-non-declared-methods-and-properties Exclude abstract methods from pointcut matching #335
- Loading branch information
Showing
12 changed files
with
151 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Go\Tests\TestProject\Application; | ||
|
||
abstract class AbstractBar implements FooInterface | ||
{ | ||
abstract public function doSomethingElse(); | ||
|
||
public function doSomeThirdThing() | ||
{ | ||
echo 'I did some third thing'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Go\Tests\TestProject\Application; | ||
|
||
interface FooInterface | ||
{ | ||
public function doSomething(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Go\Tests\TestProject\Aspect; | ||
|
||
use Go\Aop\Aspect; | ||
use Go\Aop\Intercept\MethodInvocation; | ||
use Go\Lang\Annotation as Pointcut; | ||
|
||
class DoSomethingAspect implements Aspect | ||
{ | ||
/** | ||
* Intercepts doSomething() | ||
* | ||
* @param MethodInvocation $invocation | ||
* | ||
* @Pointcut\After("execution(public Go\Tests\TestProject\Application\*->doSomething(*)) || execution(public Go\Tests\TestProject\Application\*->doSomethingElse(*))") | ||
*/ | ||
public function afterDoSomething() | ||
{ | ||
echo 'It does something else after something is done.'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Go\Functional; | ||
|
||
use PHPUnit_Framework_TestCase as TestCase; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
use Symfony\Component\Process\Process; | ||
|
||
abstract class BaseFunctionalTest extends TestCase | ||
{ | ||
protected static $projectDir = __DIR__ . '/../../Fixtures/project'; | ||
protected static $aspectCacheDir = __DIR__ . '/../../Fixtures/project/var/cache/aspect'; | ||
protected static $consolePath = __DIR__ . '/../../Fixtures/project/bin/console'; | ||
protected static $frontControllerPath = __DIR__ . '/../../Fixtures/project/web/index.php'; | ||
|
||
protected static function clearCache() | ||
{ | ||
$filesystem = new Filesystem(); | ||
|
||
if ($filesystem->exists(self::$aspectCacheDir)) { | ||
$filesystem->remove(self::$aspectCacheDir); | ||
} | ||
} | ||
|
||
protected static function warmUp() | ||
{ | ||
return self::exec('cache:warmup:aop'); | ||
} | ||
|
||
protected static function exec($command, $args = '') | ||
{ | ||
$commandStatement = sprintf('php %s %s %s %s', | ||
self::$consolePath, | ||
$command, | ||
self::$frontControllerPath, | ||
$args | ||
); | ||
|
||
$process = new Process($commandStatement); | ||
|
||
$process->run(); | ||
|
||
self::assertTrue($process->isSuccessful(), sprintf('Unable to execute "%s" command.', $command)); | ||
|
||
return $process->getOutput(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Go\Functional; | ||
|
||
class MethodWeavingTest extends BaseFunctionalTest | ||
{ | ||
public function setUp() | ||
{ | ||
self::warmUp(); | ||
} | ||
|
||
/** | ||
* test for https://github.com/goaop/framework/issues/335 | ||
*/ | ||
public function testItDoesNotWeaveAbstractMethods() | ||
{ | ||
// it weaves Main class | ||
$this->assertTrue(file_exists(self::$aspectCacheDir.'/_proxies/src/Application/Main.php')); | ||
$this->assertTrue(file_exists(self::$aspectCacheDir.'/src/Application/Main.php')); | ||
|
||
// it does not weaves AbstractBar class | ||
$this->assertFalse(file_exists(self::$aspectCacheDir.'/_proxies/src/Application/AbstractBar.php')); | ||
$this->assertFalse(file_exists(self::$aspectCacheDir.'/src/Application/AbstractBar.php')); | ||
} | ||
} |