Пример #1
0
 /**
  *  test CRUD (temp: for one record) for future create data providers
  * @dataProvider objectsProvider
  */
 public function testObjectCRUD($data)
 {
     // try to add one folder to root tree
     $obj = new \CB\Objects\Object();
     // first create object
     $data['id'] = $obj->create($data);
     $this->assertTrue($data['id'] > 0, ' Error on Object create');
     // second read created object
     $obj->load($data['id']);
     $read_data = $obj->getData();
     $this->assertArraySubset($data, $read_data, false, ' readed data: ' . print_r($read_data, true));
     // third update created object
     $data['name'] = $data['name'] . ' (updated)';
     $data['data']['_title'] = $data['data']['_title'] . ' (updated)';
     $obj->update($data);
     $obj->load($data['id']);
     $read_data = $obj->getData();
     $this->assertArraySubset($data, $read_data, false, ' error on updated object data ');
     // four delete object
     $obj->delete(false);
     $obj->delete(true);
     $obj->load($data['id']);
     $read_data = $obj->getData();
     $this->assertTrue(empty($read_data['id']), 'error delete object data');
 }
Пример #2
0
 public static function deleteObject($id)
 {
     $file = new \CB\Objects\Object($id);
     $file->delete();
     \CB\Solr\Client::runCron();
 }