Bake\Shell\Task\TestTask::getTestableMethods PHP Метод

getTestableMethods() публичный Метод

No parent methods will be returned
public getTestableMethods ( string $className ) : array
$className string Name of class to look at.
Результат array Array of method names.
    public function getTestableMethods($className)
    {
        $class = new ReflectionClass($className);
        $out = [];
        foreach ($class->getMethods() as $method) {
            if ($method->getDeclaringClass()->getName() !== $className) {
                continue;
            }
            if (!$method->isPublic()) {
                continue;
            }
            $out[] = $method->getName();
        }
        return $out;
    }

Usage Example

Пример #1
0
 /**
  * Test that method introspection pulls all relevant non parent class
  * methods into the test case.
  *
  * @return void
  */
 public function testMethodIntrospection()
 {
     $result = $this->Task->getTestableMethods('Bake\\Test\\App\\Model\\Table\\ArticlesTable');
     $expected = ['initialize', 'findpublished', 'dosomething', 'dosomethingelse'];
     $this->assertEquals($expected, array_map('strtolower', $result));
 }