private static function generateExtensionMap() { // get a list of classes $classes = array_unique(array_merge(array_keys(ClassInfo::allClasses()), get_declared_classes())); // die(print_r($classes,1)); // Silverstripe has broken clases floating around, we need to blacklist them or it's bad times $blacklist = array('SapphireTestReporter', 'SapphireTest', 'SapphireTestSuite', 'CliTestReporter', 'SilverStripeListener', 'TeamCityListener', 'SS_TestListener'); $blacklistLC = array_map('strtolower', $blacklist); // init some vars $extMap = $dOClasses = $dODClasses = array(); // Sort Classes foreach ($classes as $class) { if (!in_array(strtolower($class), $blacklistLC)) { // this breaks when we start looking at some of the broken requires in SapphireTest if (is_subclass_of($class, 'DataObject')) { $dOClasses[] = $class; } if (is_subclass_of($class, 'Extension')) { $dODClasses[] = $class; } } } // Find out what is applied to what foreach ($dODClasses as $dOD) { foreach ($dOClasses as $dO) { if (Object::has_extension($dO, $dOD)) { $extMap[$dOD][] = $dO; } } } // Cache the map self::$extensionMap = $extMap; }
function testUpdater() { $mock = Phockito::mock('ArrayList'); $this->assertContains(get_class($mock), ClassInfo::allClasses()); $this->assertContains(get_class($mock), ClassInfo::subclassesFor('ViewableData')); $this->assertContains(get_class($mock), ClassInfo::implementorsOf('SS_List')); $mock = Phockito::mock('SS_List'); $this->assertContains(get_class($mock), ClassInfo::allClasses()); $this->assertContains(get_class($mock), ClassInfo::implementorsOf('SS_List')); }
public function browse() { $classes = ClassInfo::subclassesFor('SapphireTest'); array_shift($classes); ksort($classes); $result = '<h1>View any of the following test classes</h1>'; $result .= '<ul>'; foreach ($classes as $class) { $result .= "<li><a href=\"{$this->Link($class)}\">{$class}</a></li>"; } $result .= '</ul>'; $result .= '<h1>View any of the following other classes</h1>'; $classes = array_keys(ClassInfo::allClasses()); sort($classes); $result .= '<ul>'; foreach ($classes as $class) { $result .= "<li><a href=\"{$this->Link($class)}\">{$class}</a></li>"; } $result .= '</ul>'; return $this->customise(array('Content' => $result))->renderWith('CodeViewer'); }
function Content() { $className = $this->urlParams['ID']; if($className && ClassInfo::exists($className)) { return $this->testAnalysis(getClassFile($className)); } else { $result = "<h1>View any of the following test classes</h1>"; $classes = ClassInfo::subclassesFor('SapphireTest'); ksort($classes); foreach($classes as $className) { if($className == 'SapphireTest') continue; $result .= "<li><a href=\"dev/viewcode/show/$className\">$className</a></li>"; } $result .= "<h1>View any of the following other classes</h1>"; global $_CLASS_MANIFEST; $classes = array_keys(ClassInfo::allClasses()); sort($classes); foreach($classes as $className) { if(preg_match('/^[A-Za-z][A-Za-z0-9]*$/', $className) && isset($_CLASS_MANIFEST[$className])) { $result .= "<li><a href=\"dev/viewcode/show/$className\">$className</a></li>"; } } return $result; } }