/**
  * Read in the API data and export the formats specified.
  *
  * @return array
  * Returns the internal (normalized) version of the api used by the various
  * exporters.
  */
 public function generate()
 {
     $reader = new Reader($this->options['controllersDir'], $this->options['namespace']);
     $api = $reader->getApi();
     // export
     foreach ($this->options['export'] as $exporter => $options) {
         $className = 'ApiCreator\\Exporters\\' . $exporter;
         if (class_exists($className)) {
             $exporter = new $className($api, $options);
             $exporter->export();
         }
     }
     return $api;
 }
 /**
  * Test that controller files get created
  *
  * TODO maybe somehow check the contents of the exported stuff
  */
 public function testFilesExported()
 {
     $namespace = 'ApiCreator\\Fixtures\\Reader';
     $reader = new Reader(__DIR__ . '/../../Fixtures/Reader', $namespace);
     $api = $reader->getApi();
     $options = array('exportDir' => self::TMP_DIR, 'newNamespace' => 'Api\\Controllers');
     $exporter = new Silex($api, $options);
     $exporter->export();
     foreach ($api['controllers'] as $controller) {
         $class = str_replace($namespace . '\\', 'Api\\Controllers\\', $controller['className']);
         $filename = self::TMP_DIR . str_replace('\\', '/', $class) . '.php';
         $this->assertTrue(file_exists($filename), 'For file: ' . $filename);
     }
 }
 /**
  * Test retrieving api array
  */
 public function testGetApi()
 {
     $reader = new Reader(__DIR__ . '/../Fixtures/Reader', 'ApiCreator\\Fixtures\\Reader');
     $api = $reader->getApi();
     $this->assertTrue(is_array($api));
     $this->assertArrayHasKey('controllers', $api);
     // TODO find a better way to figure out this count because if someone adds
     // another controller, they'll have to update this line too, haha
     $this->assertEquals(2, count($api['controllers']));
     // Test that it found controllers in the right namespace
     foreach ($api['controllers'] as $controller) {
         $this->assertRegExp('/ApiCreator\\\\Fixtures\\\\Reader/', $controller['className']);
     }
     // TODO how to test the rest of the stuff? huge array
 }