public function generateDBEntries() { $peter = ApiTest_Author::create(array('Name' => 'Peter', 'IsMan' => true)); $marie = ApiTest_Author::create(array('Name' => 'Marie', 'IsMan' => false)); $bible = ApiTest_Book::create(array('Title' => 'The Bible', 'Pages' => 2000)); $kamasutra = ApiTest_Book::create(array('Title' => 'Kama Sutra', 'Pages' => 1000)); $helsinki = ApiTest_Library::create(array('Name' => 'Helsinki')); $paris = ApiTest_Library::create(array('Name' => 'Paris')); // write to DB $peter->write(); $marie->write(); $bible->write(); $kamasutra->write(); $helsinki->write(); $paris->write(); // relations $peter->Books()->add($bible); $marie->Books()->add($kamasutra); $helsinki->Books()->add($bible); $helsinki->Books()->add($kamasutra); $paris->Books()->add($kamasutra); // since it doesn't seem to be called automatically $ext = new RESTfulAPI_GroupExtension(); $ext->requireDefaultRecords(); }
/** * Checks record deletion */ public function testDeleteModel() { $firstRecord = ApiTest_Book::get()->first(); $qh = $this->getQueryHandler(); $request = $this->getHTTPRequest('DELETE', 'ApiTest_Book'); $result = $qh->deleteModel('ApiTest_Book', $firstRecord->ID, $request); $deletedRecord = DataObject::get_by_id('ApiTest_Book', $firstRecord->ID); $this->assertFalse($deletedRecord, 'Delete model should delete a database record'); }