public function testRecordResetDataWithString() { $class_name = 'ResetTest'; $cluster_id = 1; $record_pos = 2; $version = 3; $record = new OrientDBRecord(); $content = $class_name . '@Key:"Value"'; $record->content = $content; $record->clusterID = $cluster_id; $record->recordPos = $record_pos; $record->version = $version; $this->assertSame('Value', $record->data->Key); $this->assertSame($class_name, $record->className); $this->assertSame($content, $record->content); $this->assertSame($record_pos, $record->recordPos); $this->assertSame($cluster_id . ':' . $record_pos, $record->recordID); $this->assertSame($version, $record->version); $this->assertSame($record->data->getKeys(), array('Key')); $record->resetData(); $this->assertSame($class_name, $record->className); $this->assertFalse(isset($record->data->Key)); $this->assertSame($cluster_id, $record->clusterID); $this->assertNull($record->recordPos); $this->assertNull($record->recordID); $this->assertNull($record->version); $this->assertNull($record->content); $this->assertSame($record->data->getKeys(), array()); }
public function testResetDataSpeed() { $steps = 10000; $new_start = microtime(true); for ($i = 0; $i < $steps; $i++) { $record = new OrientDBRecord(); $record->className = 'TestClass'; $record->data->field1 = 'Data 1'; $record->data->field2 = 13121982; $record->data->field3 = true; } $new_end = microtime(true) - $new_start; $reset_start = microtime(true); $record = new OrientDBRecord(); for ($i = 0; $i < $steps; $i++) { $record->resetData(); $record->data->field1 = 'Data 1'; $record->data->field2 = 13121982; $record->data->field3 = true; } $reset_end = microtime(true) - $reset_start; $this->assertLessThanOrEqual($new_end, $reset_end, $new_end . ' !> ' . $reset_end); }