コード例 #1
0
 /**
  * @covers LightnCandy\SafeString::escapeTemplate
  */
 public function testOn_escapeTemplate()
 {
     $method = new \ReflectionMethod('LightnCandy\\SafeString', 'escapeTemplate');
     $this->assertEquals('abc', $method->invokeArgs(null, array_by_ref(array('abc'))));
     $this->assertEquals('a\\\\bc', $method->invokeArgs(null, array_by_ref(array('a\\bc'))));
     $this->assertEquals('a\\\'bc', $method->invokeArgs(null, array_by_ref(array('a\'bc'))));
 }
コード例 #2
0
ファイル: Controller.php プロジェクト: kennyma/Jolt
 public function execute($argv)
 {
     if (!is_array($argv)) {
         $argv = array($argv);
     }
     $argc = count($argv);
     if (empty($this->action)) {
         throw new \Jolt\Exception('controller_action_not_set');
     }
     try {
         $action = new \ReflectionMethod($this, $this->action);
     } catch (\ReflectionException $e) {
         throw new \Jolt\Exception('controller_action_not_part_of_class');
     }
     $paramCount = $action->getNumberOfRequiredParameters();
     if ($paramCount != $argc && $paramCount > $argc) {
         $argv = array_pad($argv, $paramCount, NULL);
     }
     ob_start();
     if ($action->isPublic()) {
         if ($action->isStatic()) {
             $action->invokeArgs(NULL, $argv);
         } else {
             $action->invokeArgs($this, $argv);
         }
     }
     $renderedController = ob_get_clean();
     if (!empty($renderedController)) {
         $this->renderedController = $renderedController;
     } else {
         $this->renderedController = $this->renderedView;
     }
     return $this->renderedController;
 }
コード例 #3
0
 /**
  * @covers LightnCandy\LightnCandy::handleError
  */
 public function testOn_handleError()
 {
     $method = new \ReflectionMethod('LightnCandy\\LightnCandy', 'handleError');
     $method->setAccessible(true);
     $this->assertEquals(false, $method->invokeArgs(null, array_by_ref(array(array('error' => array())))));
     $this->assertEquals(true, $method->invokeArgs(null, array_by_ref(array(array('error' => array('some error'), 'flags' => array('errorlog' => 0, 'exception' => 0))))));
 }
コード例 #4
0
ファイル: TokenTest.php プロジェクト: shile23/ToDo-separated
 /**
  * @covers LightnCandy\Token::toString
  */
 public function testOn_toString()
 {
     $method = new \ReflectionMethod('LightnCandy\\Token', 'toString');
     $this->assertEquals('c', $method->invokeArgs(null, array_by_ref(array(array(0, 'a', 'b', 'c', 'd', 'e')))));
     $this->assertEquals('cd', $method->invokeArgs(null, array_by_ref(array(array(0, 'a', 'b', 'c', 'd', 'e', 'f')))));
     $this->assertEquals('qd', $method->invokeArgs(null, array_by_ref(array(array(0, 'a', 'b', 'c', 'd', 'e', 'f'), array(3 => 'q')))));
 }
コード例 #5
0
ファイル: OrderByTraitTest.php プロジェクト: ollietb/sulu
 /**
  * @dataProvider orderByProvider
  */
 public function testAddOrderBy($alias, $orderBy, $expectedOrderBy)
 {
     foreach ($expectedOrderBy as $field => $order) {
         $this->queryBuilder->addOrderBy($field, $order)->shouldBeCalledTimes(1);
     }
     $this->addOrderByFunction->invokeArgs($this->orderByTrait, [$this->queryBuilder->reveal(), $alias, $orderBy]);
 }
コード例 #6
0
ファイル: DssgTest.php プロジェクト: gsavastano/dssg
 public function testRelToAbs()
 {
     $method = new ReflectionMethod('gsavastano\\Dssg\\Dssg', 'relToAbs');
     $method->setAccessible(TRUE);
     $this->assertEquals('http://www.example.com/rel2abs', $method->invokeArgs(new Dssg(), array('/rel2abs', 'http://www.example.com/')));
     $this->assertEquals('http://www.example.com/../rel2abs', $method->invokeArgs(new Dssg(), array('../rel2abs', 'http://www.example.com/')));
     $this->assertNotEquals('http://www.example.com/rel2abs', $method->invokeArgs(new Dssg(), array('http://example.com/rel2abs', 'http://www.example.com/')));
 }
コード例 #7
0
 /**
  * Call a class reference method with set parameters.
  * @param $classInstance instantiated class name
  */
 public function call($classInstance)
 {
     if (isset($this->parameters)) {
         $this->method->invokeArgs($classInstance, $this->parameters);
     } else {
         $this->method->invoke($classInstance);
     }
 }
コード例 #8
0
ファイル: Reflection.php プロジェクト: ptrofimov/xpmock
 public function __call($methodName, array $args)
 {
     $method = new \ReflectionMethod($this->class, $methodName);
     if (!$method->isPublic()) {
         $method->setAccessible(true);
     }
     return $method->isStatic() ? $method->invokeArgs(null, $args) : $method->invokeArgs($this->object, $args);
 }
コード例 #9
0
ファイル: CompilerTest.php プロジェクト: zordius/lightncandy
 /**
  * @covers LightnCandy\Compiler::addUsageCount
  */
 public function testOn_addUsageCount()
 {
     $method = new \ReflectionMethod('LightnCandy\\Compiler', 'addUsageCount');
     $method->setAccessible(true);
     $this->assertEquals(1, $method->invokeArgs(null, array_by_ref(array(array('usedCount' => array('test' => array())), 'test', 'testname'))));
     $this->assertEquals(3, $method->invokeArgs(null, array_by_ref(array(array('usedCount' => array('test' => array('testname' => 2))), 'test', 'testname'))));
     $this->assertEquals(5, $method->invokeArgs(null, array_by_ref(array(array('usedCount' => array('test' => array('testname' => 2))), 'test', 'testname', 3))));
 }
コード例 #10
0
ファイル: EncoderTest.php プロジェクト: zordius/lightncandy
 /**
  * @covers LightnCandy\Encoder::encq
  */
 public function testOn_encq()
 {
     $method = new \ReflectionMethod('LightnCandy\\Encoder', 'encq');
     $this->assertEquals('a', $method->invokeArgs(null, array_by_ref(array(array('flags' => array('mustlam' => 0, 'lambda' => 0)), 'a'))));
     $this->assertEquals('a&b', $method->invokeArgs(null, array_by_ref(array(array('flags' => array('mustlam' => 0, 'lambda' => 0)), 'a&b'))));
     $this->assertEquals('a'b', $method->invokeArgs(null, array_by_ref(array(array('flags' => array('mustlam' => 0, 'lambda' => 0)), 'a\'b'))));
     $this->assertEquals('`a'b', $method->invokeArgs(null, array_by_ref(array(array('flags' => array('mustlam' => 0, 'lambda' => 0)), '`a\'b'))));
 }
コード例 #11
0
 public function testCountryCodeSearch()
 {
     $method = new ReflectionMethod('Player', 'countryCode');
     $method->setAccessible(TRUE);
     $player = new Player(null);
     $this->assertEquals('FI', $method->invokeArgs($player, array('Finland')));
     $this->assertEquals('UNK', $method->invokeArgs($player, array('Random')));
     $this->assertEquals('UNK', $method->invokeArgs($player, array(123)));
 }
コード例 #12
0
ファイル: PartialTest.php プロジェクト: zordius/lightncandy
 /**
  * @covers LightnCandy\Partial::prePartial
  */
 public function testOn_prePartial()
 {
     $method = new \ReflectionMethod('LightnCandy\\Partial', 'prePartial');
     $method->setAccessible(true);
     $this->assertEquals('hey', $method->invokeArgs(null, array_by_ref(array(array('prepartial' => false), 'hey', 'haha'))));
     $this->assertEquals('haha-hoho', $method->invokeArgs(null, array_by_ref(array(array('prepartial' => function ($cx, $tmpl, $name) {
         return "{$name}-{$tmpl}";
     }), 'hoho', 'haha'))));
 }
コード例 #13
0
ファイル: MysqlDriverTest.php プロジェクト: RayManOff/t4
 public function testCreateTableDDL()
 {
     $driver = new \T4\Dbal\Drivers\Mysql();
     $reflector = new ReflectionMethod($driver, 'createTableDDL');
     $reflector->setAccessible(true);
     $this->assertEquals('CREATE TABLE `foo`' . "\n" . '(' . "\n" . '`__id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,' . "\n" . 'PRIMARY KEY (`__id`)' . "\n" . ')', $reflector->invokeArgs($driver, ['foo', []]));
     $this->assertEquals('CREATE TABLE `foo`' . "\n" . '(' . "\n" . '`__id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,' . "\n" . '`foo` INT(11),' . "\n" . '`bar` VARCHAR(255),' . "\n" . 'PRIMARY KEY (`__id`)' . "\n" . ')', $reflector->invokeArgs($driver, ['foo', ['foo' => ['type' => 'int'], 'bar' => ['type' => 'string']]]));
     $this->assertEquals('CREATE TABLE `foo`' . "\n" . '(' . "\n" . '`__id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,' . "\n" . '`lnk` BIGINT UNSIGNED NOT NULL DEFAULT \'0\',' . "\n" . '`foo` INT(11),' . "\n" . '`bar` VARCHAR(255),' . "\n" . 'PRIMARY KEY (`__id`),' . "\n" . 'INDEX `lnk_idx` (`lnk`)' . "\n" . ')', $reflector->invokeArgs($driver, ['foo', ['lnk' => ['type' => 'link'], 'foo' => ['type' => 'int'], 'bar' => ['type' => 'string']]]));
 }
コード例 #14
0
ファイル: PgsqlDriverTest.php プロジェクト: RayManOff/t4
 public function testCreateTableDDL()
 {
     $driver = new \T4\Dbal\Drivers\Pgsql();
     $reflector = new ReflectionMethod($driver, 'createTableDDL');
     $reflector->setAccessible(true);
     $this->assertEquals(['CREATE TABLE "foo"' . "\n" . '("__id" BIGSERIAL PRIMARY KEY)'], $reflector->invokeArgs($driver, ['foo', []]));
     $this->assertEquals(['CREATE TABLE "foo"' . "\n" . '("__id" BIGSERIAL PRIMARY KEY, "foo" INTEGER, "bar" VARCHAR)'], $reflector->invokeArgs($driver, ['foo', ['foo' => ['type' => 'int'], 'bar' => ['type' => 'string']]]));
     $this->assertEquals(['CREATE TABLE "foo"' . "\n" . '("__id" BIGSERIAL PRIMARY KEY, "lnk" BIGINT NOT NULL DEFAULT \'0\', "foo" INTEGER, "bar" VARCHAR)', 'CREATE INDEX ON "foo" ("lnk")'], $reflector->invokeArgs($driver, ['foo', ['lnk' => ['type' => 'link'], 'foo' => ['type' => 'int'], 'bar' => ['type' => 'string']]]));
 }
コード例 #15
0
 public function testEvalGroupParsesSimpleAndsAndOrs()
 {
     $reflectionMethod = new \ReflectionMethod($this->evaluator, 'evalGroup');
     $reflectionMethod->setAccessible(\true);
     $result = $reflectionMethod->invokeArgs($this->evaluator, [[1 => '0|0|0|1|0&1']]);
     $this->assertSame(1, $result);
     $result = $reflectionMethod->invokeArgs($this->evaluator, [[1 => '0|0|0|0|0&0']]);
     $this->assertSame(0, $result);
 }
コード例 #16
0
 public function testIsFloatScalePrecise()
 {
     $reflMethod = new \ReflectionMethod('MoneyLaundry\\Filter\\AbstractFilter', 'isFloatScalePrecise');
     $reflMethod->setAccessible(true);
     $mock = $this->getMockBuilder('MoneyLaundry\\Filter\\AbstractFilter')->enableProxyingToOriginalMethods()->getMockForAbstractClass();
     $this->assertTrue($reflMethod->invokeArgs($mock, [1.25, 2]));
     $this->assertFalse($reflMethod->invokeArgs($mock, [1.255, 2]));
     $reflMethod->setAccessible(false);
 }
コード例 #17
0
 /**
  *
  */
 public function testGetResponseReturnsSpecificValueIfKeyIsSupplied()
 {
     $method = new \ReflectionMethod('\\PutIO\\Helpers\\HTTP\\HTTPHelper', 'getResponse');
     $method->setAccessible(\true);
     $this->assertSame('yay', $method->invokeArgs($this->helper, ['{"valid": "json", "robots": "yay"}', \false, 'robots']));
     $this->assertFalse($method->invokeArgs($this->helper, ['{"valid": "json", "robots": "yay"}', \false, 'this key does not exist']));
     $this->assertTrue($method->invokeArgs($this->helper, ['{"status": "OK"}', \true]));
     $this->assertSame(['valid' => 'json', 'robots' => 'yay'], $method->invokeArgs($this->helper, ['{"valid": "json", "robots": "yay"}', \false, '']));
 }
コード例 #18
0
ファイル: ContextTest.php プロジェクト: zordius/lightncandy
 /**
  * @covers LightnCandy\Context::updateHelperTable
  */
 public function testOn_updateHelperTable()
 {
     $method = new \ReflectionMethod('LightnCandy\\Context', 'updateHelperTable');
     $method->setAccessible(true);
     $this->assertEquals(array(), $method->invokeArgs(null, array_by_ref(array(array(), array()))));
     $this->assertEquals(array('flags' => array('exhlp' => 1), 'helpers' => array('abc' => 1)), $method->invokeArgs(null, array_by_ref(array(array('flags' => array('exhlp' => 1)), array('helpers' => array('abc'))))));
     $this->assertEquals(array('error' => array('You provide a custom helper named as \'abc\' in options[\'helpers\'], but the function abc() is not defined!'), 'flags' => array('exhlp' => 0)), $method->invokeArgs(null, array_by_ref(array(array('error' => array(), 'flags' => array('exhlp' => 0)), array('helpers' => array('abc'))))));
     $this->assertEquals(array('flags' => array('exhlp' => 1), 'helpers' => array('\\LightnCandy\\Runtime::raw' => '\\LightnCandy\\Runtime::raw')), $method->invokeArgs(null, array_by_ref(array(array('flags' => array('exhlp' => 1), 'helpers' => array()), array('helpers' => array('\\LightnCandy\\Runtime::raw'))))));
     $this->assertEquals(array('flags' => array('exhlp' => 1), 'helpers' => array('test' => '\\LightnCandy\\Runtime::raw')), $method->invokeArgs(null, array_by_ref(array(array('flags' => array('exhlp' => 1), 'helpers' => array()), array('helpers' => array('test' => '\\LightnCandy\\Runtime::raw'))))));
 }
コード例 #19
0
ファイル: SahiDriverTest.php プロジェクト: Vallach/behat-poc
 public function testPrepareXPath()
 {
     $driver = $this->getSession()->getDriver();
     // Make the method accessible for testing purposes
     $method = new \ReflectionMethod('Behat\\Mink\\Driver\\SahiDriver', 'prepareXPath');
     $method->setAccessible(true);
     $this->assertEquals('No quotes', $method->invokeArgs($driver, array('No quotes')));
     $this->assertEquals("Single quote'", $method->invokeArgs($driver, array("Single quote'")));
     $this->assertEquals('Double quote\\"', $method->invokeArgs($driver, array('Double quote"')));
 }
コード例 #20
0
 public function testStringMessage()
 {
     $mock = $this->getMockForAbstractClass('\\Concrete\\Core\\Validator\\AbstractTranslatableValidator');
     $method = new \ReflectionMethod($mock, 'getErrorString');
     $method->setAccessible(true);
     /** @type \Concrete\Core\Validator\AbstractTranslatableValidator $mock */
     $mock->setErrorString(5, 'ERROR');
     $this->assertEquals('ERROR', $method->invokeArgs($mock, array(5, '')));
     $this->assertEquals('default', $method->invokeArgs($mock, array(1, '', 'default')));
 }
コード例 #21
0
 /**
  * @dataProvider validateConfigProvider
  */
 public function testValidateConfig($options, $expectedOptions = false, $expectedException = false, $expectedExceptionMessage = false)
 {
     $factory = new DropboxAdapterFactory($options);
     if ($expectedException) {
         $this->setExpectedException($expectedException, $expectedExceptionMessage);
     }
     $this->method->invokeArgs($factory, []);
     if (is_array($expectedOptions)) {
         $this->assertEquals($expectedOptions, $this->property->getValue($factory));
     }
 }
コード例 #22
0
ファイル: ExporterTest.php プロジェクト: zordius/lightncandy
 /**
  * @covers LightnCandy\Exporter::closure
  */
 public function testOn_closure()
 {
     $method = new \ReflectionMethod('LightnCandy\\Exporter', 'closure');
     $method->setAccessible(true);
     $this->assertEquals('function($a) {return;}', $method->invokeArgs(null, array_by_ref(array(array('flags' => array('standalone' => 0)), function ($a) {
         return;
     }))));
     $this->assertEquals('function($a) {return;}', $method->invokeArgs(null, array_by_ref(array(array('flags' => array('standalone' => 0)), function ($a) {
         return;
     }))));
 }
コード例 #23
0
 public static function __callStatic($name, $arguments)
 {
     $method = new \ReflectionMethod('\\BCC\\EnumerableUtility\\Stringer', $name);
     if ($method->isStatic()) {
         $result = $method->invokeArgs(null, $arguments);
     } else {
         $result = $method->invokeArgs(new Stringer($arguments[0]), \array_slice($arguments, 1));
     }
     if ($result instanceof Stringer) {
         return (string) $result;
     }
     return $result;
 }
コード例 #24
0
 public function testGetExcerpt()
 {
     $method = new ReflectionMethod(\Junky\PhpPrettyPrint\Html\HtmlBuilder::class, 'getExcerpt');
     $method->setAccessible(true);
     $really_long_string = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.Lorem ipsum dolor sit amet, consectetur adipiscing elit.Lorem ipsum dolor sit amet, consectetur adipiscing elit.Lorem ipsum dolor sit amet, consectetur adipiscing elit.Lorem ipsum dolor sit amet, consectetur adipiscing elit.Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
     // Default 250
     // + 3 trailing dots
     $this->assertEquals($method->invokeArgs(new HtmlBuilder(), [$really_long_string => 250]), 250);
     // less than 250
     $this->assertEquals($method->invokeArgs(new HtmlBuilder(), [$really_long_string => 153]), 153);
     // excerpt is false
     // god damn it phpunit...
     $this->assertEquals($method->invokeArgs(new HtmlBuilder(), [$really_long_string => strlen($really_long_string)]), strlen($really_long_string));
 }
コード例 #25
0
ファイル: ValidationTest.php プロジェクト: betawax/role-model
 public function testProcessRules()
 {
     $model = new RoleModelValidationStub(array(), self::validatorMock());
     $rules = RoleModelValidationStub::$rules;
     $processRules = new ReflectionMethod($model, 'processRules');
     $processRules->setAccessible(true);
     $expected = array('name' => 'required', 'email' => 'unique:foobar,email,');
     $result = $processRules->invokeArgs($model, array($rules));
     $this->assertEquals($expected, $result);
     $model->id = 42;
     $expected = array('name' => 'required', 'email' => 'unique:foobar,email,42');
     $result = $processRules->invokeArgs($model, array($rules));
     $this->assertEquals($expected, $result);
 }
コード例 #26
0
ファイル: ActionInfo.php プロジェクト: sanzhumu/xaircraft1.1
 public function invoke(array $params = null, array $posts = null)
 {
     $this->attributes->invoke();
     $this->controller->attributes->invoke();
     $args = Argument::createArgs($this->attributes, $this->parameters, $params, $posts);
     //        foreach ($this->parameters as $parameter) {
     //            var_dump($parameter->getClass());
     //            if (array_key_exists($parameter->name, $params)) {
     //                $args[$parameter->name] = $params[$parameter->name];
     //            } else {
     //                $args[$parameter->name] = null;
     //            }
     //        }
     return $this->reflector->invokeArgs($this->controller, $args);
 }
 public function invoke($methodName, array $methodArguments)
 {
     $reflectionMethod = new ReflectionMethod($this->person, $methodName);
     if (substr($methodName, 0, 3) == "get") {
         return $reflectionMethod->invokeArgs($this->person, $methodArguments);
     } else {
         if ($methodName == "setHotOrNotRating") {
             throw new BadMethodCallException("Illegal access");
         } else {
             if (substr($methodName, 0, 3) == "set") {
                 return $reflectionMethod->invokeArgs($this->person, $methodArguments);
             }
         }
     }
     return NULL;
 }
コード例 #28
0
ファイル: Core.php プロジェクト: madeinnordeste/kohana-aws
 /**
  * Creates alias to all native methods of the resource.
  *
  * @param   string  $method  method name
  * @param   mixed   $args    arguments
  * @return  mixed
  */
 public function __call($method, $args)
 {
     $class = get_called_class();
     $obj = $class::instance();
     $method = new ReflectionMethod($obj, $method);
     return $method->invokeArgs($obj, $args);
 }
コード例 #29
0
ファイル: reflection.php プロジェクト: JudonH/writer
function xx4($i)
{
    $xx = 'test';
    $x = new $xx();
    $m = new ReflectionMethod($x, 'xx');
    $m->invokeArgs($x, array($i));
}
コード例 #30
0
ファイル: CInlineAction.php プロジェクト: IuriiP/yii-tracker
 /**
  * Runs the action.
  * The action method defined in the controller is invoked.
  * This method is required by {@link CAction}.
  */
 public function run()
 {
     $controller = $this->getController();
     $methodName = 'action' . $this->getId();
     $method = new ReflectionMethod($controller, $methodName);
     if (($n = $method->getNumberOfParameters()) > 0) {
         $params = array();
         foreach ($method->getParameters() as $i => $param) {
             $name = $param->getName();
             if (isset($_GET[$name])) {
                 if ($param->isArray()) {
                     $params[] = is_array($_GET[$name]) ? $_GET[$name] : array($_GET[$name]);
                 } else {
                     if (!is_array($_GET[$name])) {
                         $params[] = $_GET[$name];
                     } else {
                         throw new CHttpException(400, Yii::t('yii', 'Your request is invalid.'));
                     }
                 }
             } else {
                 if ($param->isDefaultValueAvailable()) {
                     $params[] = $param->getDefaultValue();
                 } else {
                     throw new CHttpException(400, Yii::t('yii', 'Your request is invalid.'));
                 }
             }
         }
         $method->invokeArgs($controller, $params);
     } else {
         $controller->{$methodName}();
     }
 }