Exemplo n.º 1
0
 /**
  * Returns a list of all classes inside a given package
  *
  * @param   lang.reflect.Package 
  * @param   bool recursive whether to include subpackages
  * @return  lang.XPClass[]
  */
 protected static function testClassesIn(Package $package, $recursive)
 {
     $r = array();
     foreach ($package->getClasses() as $class) {
         if (!$class->isSubclassOf('unittest.TestCase') || Modifiers::isAbstract($class->getModifiers())) {
             continue;
         }
         $r[] = $class;
     }
     if ($recursive) {
         foreach ($package->getPackages() as $package) {
             $r = array_merge($r, self::testClassesIn($package, $recursive));
         }
     }
     return $r;
 }
Exemplo n.º 2
0
 /**
  * Get all test cases
  *
  * @param   var[] arguments
  * @return  unittest.TestCase[]
  */
 public function testCasesWith($arguments)
 {
     if (NULL === ($cl = $this->findLoaderFor($this->folder->getURI()))) {
         throw new IllegalArgumentException($this->folder->toString() . ' is not in class path');
     }
     $l = strlen($cl->path);
     $e = -strlen(xp::CLASS_FILE_EXT);
     $it = new FilteredIOCollectionIterator(new FileCollection($this->folder), new ExtensionEqualsFilter(xp::CLASS_FILE_EXT), TRUE);
     $cases = array();
     foreach ($it as $element) {
         $name = strtr(substr($element->getUri(), $l, $e), DIRECTORY_SEPARATOR, '.');
         $class = XPClass::forName($name);
         if (!$class->isSubclassOf('unittest.TestCase') || Modifiers::isAbstract($class->getModifiers())) {
             continue;
         }
         $cases = array_merge($cases, $this->testCasesInClass($class, $arguments));
     }
     if (empty($cases)) {
         throw new IllegalArgumentException('Cannot find any test cases in ' . $this->folder->toString());
     }
     return $cases;
 }
Exemplo n.º 3
0
 /**
  * Asserts given modifiers do not contain abstract
  *
  * @param   int modifiers
  * @throws  unittest.AssertionFailedError
  */
 protected function assertNotAbstract($modifiers)
 {
     $this->assertFalse(Modifiers::isAbstract($modifiers), implode(' | ', Modifiers::namesOf($modifiers)));
 }
Exemplo n.º 4
0
 public function abstractModifier()
 {
     $this->assertTrue(Modifiers::isAbstract(MODIFIER_ABSTRACT));
     $this->assertEquals('public abstract', Modifiers::stringOf(MODIFIER_ABSTRACT));
 }