Example #1
0
 public function testMuxCompiler()
 {
     $mux = new Mux();
     $mux->add('/hello/:name', array('FooController', 'index'));
     $mux->compile("hello_mux.php");
     $mux2 = new Mux();
     $mux2->add('/bye/:name', array('FooController', 'index'));
     $mux2->compile("bye_mux.php");
     $compiler = new MuxCompiler();
     ok($compiler->load("hello_mux.php"));
     ok($compiler->load("bye_mux.php"));
     $compiler->compileReflectionParameters();
     ok($compiler->compile("merged_mux.php"));
     path_ok("merged_mux.php");
     $mux = (require "merged_mux.php");
     ok($mux);
     $routes = $mux->getRoutes();
     ok($routes);
     count_ok(2, $routes);
     ok($mux->dispatch('/hello/John'));
     ok($mux->dispatch('/bye/John'));
     unlink("merged_mux.php");
     unlink("hello_mux.php");
     unlink("bye_mux.php");
 }
 public function testSchemaGenerator()
 {
     $g = new SchemaGenerator($this->config, $this->logger);
     $g->setForceUpdate(true);
     $schemas = $this->getModels();
     foreach ($schemas as $schema) {
         if ($result = $g->generateCollectionClass($schema)) {
             list($class, $file) = $result;
             ok($class);
             ok($file);
             path_ok($file);
             $this->syntaxTest($file);
         }
         if ($classMap = $g->generate(array($schema))) {
             foreach ($classMap as $class => $file) {
                 ok($class);
                 ok($file);
                 path_ok($file, $file);
                 // $this->syntaxTest($file);
                 require_once $file;
             }
         }
         $pk = $schema->findPrimaryKey();
         $this->assertNotNull($pk, "Find primary key from " . get_class($schema));
         $model = $schema->newModel();
         $this->assertNotNull($model);
         $collection = $schema->newCollection();
         $this->assertNotNull($collection);
     }
 }
Example #3
0
 /**
  * @dataProvider packageNameProvider
  */
 public function testInstallPackages($packageName)
 {
     if (!file_exists('tmp')) {
         mkdir('tmp');
     }
     chdir('tmp');
     $logger = new CLIFramework\Logger();
     $installer = new PhpBrew\ExtensionInstaller($logger);
     ok($installer);
     $installedPath = $installer->installFromPecl($packageName);
     chdir('..');
     path_ok($installedPath);
 }
 /**
  * @dataProvider schemaProvider
  */
 public function testGenerateMethod($g, $schema)
 {
     if ($classMap = $g->generate(array($schema))) {
         foreach ($classMap as $class => $file) {
             ok($class);
             ok($file);
             path_ok($file, $file);
             // $this->syntaxTest($file);
             require_once $file;
         }
     }
     $pk = $schema->findPrimaryKey();
     $this->assertNotNull($pk, "Find primary key from " . get_class($schema));
     $model = $schema->newModel();
     $this->assertNotNull($model);
     $collection = $schema->newCollection();
     $this->assertNotNull($collection);
 }
Example #5
0
 /**
  * @dataProvider schemaProvider
  */
 public function testSchemaProxyGeneration($g, $schema)
 {
     if ($result = $g->generateSchemaProxyClass($schema)) {
         list($class, $file) = $result;
         ok($class);
         ok($file);
         path_ok($file);
         $this->syntaxTest($file);
     }
 }