/** * Returns array list of all generators in the specified class * * @author Alexander Morland * @param string $class * @return array */ public static function listMethods($class) { if (is_null(self::$Faker)) { self::$Faker = new Faker(); } $methods = get_class_methods(self::$Faker->{$class}); $ret = array(); foreach ($methods as $one) { if (substr($one, 0, 2) != '__' && substr($one, 0, 8) != 'generate') { $ret[$class . '->' . $one] = $one; } } return $ret; }
function testDummyWrapper() { App::import('vendor', 'Dummy.DummyWrapper'); $classes = DummyWrapper::listClasses(false); debug(array('code' => 'DummyWrapper::listClasses(false)', 'classes' => $classes)); $english_generators = DummyWrapper::listMethods('English'); debug(array('code' => 'DummyWrapper::listMethods("English")', 'english_generators' => $english_generators)); $name = DummyWrapper::generate('English', 'title', array('max' => 200)); debug(array('code' => 'DummyWrapper::generate("English","title", array("max" => 200))', 'english title' => $name)); $subclasses = DummyWrapper::listSubClasses('Address'); debug(array('code' => 'DummyWrapper::listSubClasses("Address")', 'classes' => $subclasses)); $uk_post_code = DummyWrapper::generate('Uk', 'post_code'); debug(array('code' => 'DummyWrapper::generate(\'Uk\',\'post_code\')', 'post_code' => $uk_post_code)); $us_post_code = DummyWrapper::generate('Usa', 'post_code'); debug(array('code' => 'DummyWrapper::generate(\'Usa\',\'post_code\')', 'post_code' => $us_post_code)); }