Example #1
0
 public function testDelete()
 {
     $obj = IXF\IXP::retrieve('IXP', self::IXP_TEST_OBJECT_ID);
     $this->assertEquals(self::IXP_TEST_OBJECT_ID, $obj->id);
     $this->assertTrue(is_string($obj->state) && strlen($obj->state));
     $this->assertTrue($obj->delete());
     sleep(1);
     $obj = IXF\IXP::retrieve('IXP', self::IXP_TEST_OBJECT_ID);
     $this->assertEquals('deleted', $obj->state);
     return;
     $obj->state = 'active';
     $obj->save();
     sleep(1);
     $obj = IXF\IXP::retrieve('IXP', self::IXP_TEST_OBJECT_ID);
     $this->assertEquals('active', $obj->state);
 }
Example #2
0
$newObjIdArray = IXF\IXP::create(["full_name" => "Test IXP", "short_name" => "TIXP"]);
if (is_array($newObjIdArray) && !isset($newObjIdArray['error'])) {
    echo "New object created with ID: " . $newObjIdArray['id'] . "\n";
} else {
    echo "FAILURE!!!\n\n";
    var_dump($newObjIdArray);
    die;
}
// retrieve it
sleep(1);
// allow mysql -> couchdb propgation
$o = IXF\IXP::retrieve($newObjIdArray['id']);
// and delete it
// delete returns true on success and clears the object
$result = $o->delete();
if ($result === true) {
    echo "Object deleted\n";
} else {
    // on failure, you get an array of the form:
    // array(1) {
    //  ["error"]=>
    //  string(49) "DoesNotExist: Ixps matching query does not exist."
    //}
    var_dump($result);
    die;
}
// and further proof
$o = IXF\IXP::retrieve($newObjIdArray['id']);
if (isset($o->error)) {
    echo "Object not found.\n";
}