/** * Try to create and delete an edge collection not using an edge object */ public function testCreateAndDeleteSystemCollectionWithoutCreatingObject() { $connection = $this->connection; $collectionHandler = new CollectionHandler($connection); $name = '_ArangoDB_PHP_TestSuite_TestCollection_02'; try { $collectionHandler->drop($name); } catch (Exception $e) { //Silence the exception } $options = array('isSystem' => true, 'waitForSync' => true); $collectionHandler->create($name, $options); $resultingCollection = $collectionHandler->get($name); $resultingAttribute = $resultingCollection->getName(); $this->assertTrue($name === $resultingAttribute, 'The created collection name and resulting collection name do not match!'); $resultingCollectionProperties = $collectionHandler->getProperties($name); $this->assertTrue($resultingCollectionProperties->getIsSystem()); $this->assertTrue($resultingCollectionProperties->getWaitForSync()); $collectionHandler->delete($name); }
/** * Test the enhanced tracer */ public function testEnhancedTracer() { //Setup $self = $this; //Hack for PHP 5.3 compatibility $enhancedTracer = function ($data) use($self) { $self->assertTrue($data instanceof TraceRequest || $data instanceof TraceResponse, '$data must be instance of TraceRequest or TraceResponse.'); $self->assertInternalType('array', $data->getHeaders(), 'Headers should be an array!'); $self->assertNotEmpty($data->getHeaders(), 'Headers should not be an empty array!'); $self->assertInternalType('string', $data->getBody(), 'Body must be a string!'); if ($data instanceof TraceRequest) { $self->assertContains($data->getMethod(), array(HttpHelper::METHOD_DELETE, HttpHelper::METHOD_GET, HttpHelper::METHOD_HEAD, HttpHelper::METHOD_PATCH, HttpHelper::METHOD_POST, HttpHelper::METHOD_PUT), 'Invalid http method!'); $self->assertInternalType('string', $data->getRequestUrl(), 'Request url must be a string!'); $self->assertEquals('request', $data->getType()); foreach ($data->getHeaders() as $header => $value) { $self->assertInternalType('string', $value, "The header value should be a string"); $self->assertInternalType('string', $header, "The header should be a string"); } } else { $self->assertInternalType('integer', $data->getHttpCode(), 'Http code must be an integer!'); $self->assertInternalType('string', $data->getHttpCodeDefinition(), 'Http code definition must be a string!'); $self->assertEquals('response', $data->getType()); $self->assertInternalType('float', $data->getTimeTaken()); } }; $options = getConnectionOptions(); $options[ConnectionOptions::OPTION_TRACE] = $enhancedTracer; $options[ConnectionOptions::OPTION_ENHANCED_TRACE] = true; $connection = new Connection($options); $collectionHandler = new CollectionHandler($connection); //Try creating a collection $collectionHandler->create('ArangoDB_PHP_TestSuite_TestTracer'); //Delete the collection try { $collectionHandler->drop('ArangoDB_PHP_TestSuite_TestTracer'); } catch (Exception $e) { } }