예제 #1
0
	public function test_insert_vocabulary()
	{
		$vocab_count = count( Vocabulary::names() );
		$params = array(
			'name' => $this->vocab_name,
			'description' => $this->vocab_desc,
			'features' => array( 'hierarchical' )
		);
		$v = new Vocabulary( $params );
		$v->insert();

		$this->assert_equal( $vocab_count + 1, count( Vocabulary::names() ), 'Count of names should increase by one' );
		$this->assert_true( in_array( $this->vocab_name, Vocabulary::names() ), 'Test vocabulary name should be in the list of names' );

		$new_v = new Vocabulary( $params );
		$results = $new_v->insert();
		$this->assert_equal( $results, FALSE );

		// Clean up
		try {
			$v->delete();
		}
		catch ( Exception $e ) {
			echo 'Caught exception: ',$e->getMessage(), "\n";
		}
	}
예제 #2
0
 public function test_rename_vocabulary()
 {
     // Set up
     // Create and insert a vocabulary
     $params = array('name' => $this->vocab_name, 'description' => $this->vocab_desc, 'features' => array('hierarchical'));
     $v = new Vocabulary($params);
     $v->insert();
     // Rename vocabulary
     $vocab_count = count(Vocabulary::names());
     Vocabulary::rename($this->vocab_name, $this->vocab_rename);
     $this->assertTrue(in_array($this->vocab_rename, Vocabulary::names()), 'New vocabulary name should be in list of vocabulary names');
     $this->assertFalse(in_array($this->vocab_name, Vocabulary::names()), 'Old vocabulary name should not be in list of vocabulary names');
     $this->assertEquals($vocab_count, count(Vocabulary::names()), 'Number of vocabularies should not change on rename');
     // Clean up
     // Delete the vocabulary
     try {
         $v->delete();
     } catch (Exception $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
     }
 }