* @copyright 2020 Copyright XEHub Corp. * @license http://www.gnu.org/licenses/lgpl-3.0-standalone.html LGPL * @link https://xpressengine.io */ namespace Xpressengine\Tests\Interception; use Mockery; use ReflectionClass; use Xpressengine\Interception\Proxy\Pass\MethodDefinitionPass; class MethodDefinitionPassTest extends \PHPUnit\Framework\TestCase { public function testApply() { $pass = new MethodDefinitionPass(); $config = $this->getProxyConfig(); $rfc = new ReflectionClass('Xpressengine\Tests\MethodDefinitionPassTest\TestTargetClass'); $methods = $rfc->getMethods(\ReflectionMethod::IS_PUBLIC); $config->shouldReceive('getTargetMethods')->once()->andReturn($methods); $code = $pass->apply($this->getTestCode(), $config); $this->assertContains('public function funcA(array $a)', $code); $this->assertContains('public function funcB(Closure $b)', $code); $this->assertNotContains('funcC', $code); $this->assertContains('use ProxyTrait', $code); } protected function getProxyConfig() { return Mockery::mock('Xpressengine\Interception\Proxy\ProxyConfig'); } protected function getTestCode() { return '