Example #1
0
 /**
  * Get allowed actions
  *
  * @return array
  */
 public function getAllowedActions()
 {
     $r = new \ReflectionCLass(get_called_class());
     $actions = array();
     foreach ($r->getMethods() as $method) {
         if (preg_match('/^doAction(.+)$/Ss', $method->getName(), $m)) {
             $actions[] = lcfirst($m[1]);
         }
     }
     return $actions;
 }
 /**
  * Performs list of common checks on parsed and runtime refelection
  *
  * @param ReflectionCLass $parsedRefClass
  * @param array $allNameGetters Optional list of getters to check
  */
 protected function performGeneralMethodComparison(ReflectionCLass $parsedRefClass, array $allNameGetters = [])
 {
     $allNameGetters = $allNameGetters ?: ['getStartLine', 'getEndLine', 'getDocComment', 'getExtension', 'getExtensionName', 'getName', 'getNamespaceName', 'getShortName', 'inNamespace', 'isAbstract', 'isCloneable', 'isFinal', 'isInstantiable', 'isInterface', 'isInternal', 'isIterateable', 'isTrait', 'isUserDefined', 'getConstants', 'getTraitNames', 'getInterfaceNames', 'getStaticProperties', 'getDefaultProperties', 'getTraitAliases'];
     $className = $parsedRefClass->getName();
     $originalRefClass = new \ReflectionClass($className);
     foreach ($allNameGetters as $getterName) {
         $expectedValue = $originalRefClass->{$getterName}();
         $actualValue = $parsedRefClass->{$getterName}();
         $this->assertSame($expectedValue, $actualValue, "{$getterName}() for class {$className} should be equal");
     }
 }