Example #1
0
File: XmlTest.php Project: tdt/core
 public function testDeleteApi()
 {
     // Delete the published definition for each test xml file.
     foreach ($this->test_data as $file) {
         $this->updateRequest('DELETE');
         $controller = \App::make('Tdt\\Core\\Definitions\\DefinitionController');
         $response = $controller->handle("xml/{$file}");
         $this->assertEquals(200, $response->getStatusCode());
     }
     // Check if everything is deleted properly.
     $definitions_count = \Definition::all()->count();
     $xml_count = \XmlDefinition::all()->count();
     $this->assertTrue($xml_count == 0);
     $this->assertTrue($definitions_count == 0);
 }
Example #2
0
 /**
  * Delete everything out of our testing database.
  */
 public static function tearDownAfterClass()
 {
     parent::tearDownAfterClass();
     \Definition::truncate();
     \CsvDefinition::truncate();
     \InstalledDefinition::truncate();
     \JsonDefinition::truncate();
     \ShpDefinition::truncate();
     \SparqlDefinition::truncate();
     \XlsDefinition::truncate();
     \XmlDefinition::truncate();
     \GeoProperty::truncate();
     \TabularColumns::truncate();
     \Geoprojection::truncate();
 }
Example #3
0
 /**
  * Seed the XML definitions
  */
 private function seedXml()
 {
     $xml_data = array('persons' => 'Auto-generated xml file about persons.');
     $added = false;
     foreach ($xml_data as $file => $description) {
         // Don't create doubles
         $definition = Definition::where('collection_uri', '=', 'xml')->where('resource_name', '=', $file)->first();
         if (empty($definition)) {
             // Create a new XmlDefinition
             $xml_def = new XmlDefinition();
             $xml_def->uri = app_path() . '/storage/data/xml/' . $file . '.xml';
             $xml_def->description = $description;
             $xml_def->save();
             // Add the XmlDefinition to the Definition
             $definition = new Definition();
             $definition->collection_uri = 'xml';
             $definition->resource_name = $file;
             $definition->source_id = $xml_def->id;
             $definition->source_type = 'XmlDefinition';
             $definition->draft = false;
             $definition->save();
             $this->command->info("Published an XML file with file name {$file} on uri (relative to the root) xml/{$file} .");
             $added = true;
         }
     }
     if (!$added) {
         $this->command->info("No XML files have been published, all of the uri's that the XML seeder wanted to use are already taken.");
     }
 }