public function testWritePointsInASingleCall() { $point1 = new Point('cpu_load_short', 0.64, array('host' => 'server01', 'region' => 'us-west'), array('cpucount' => 10), 1435222310); $point2 = new Point('cpu_load_short', 0.84); $payloadExpected = "{$point1}\n{$point2}"; $this->mockClient->expects($this->once())->method('write')->with($this->equalTo($this->db->getName()), $this->equalTo($payloadExpected))->will($this->returnValue(true)); $this->db->writePoints(array($point1, $point2)); }
public function testNotExists() { $database = new Database('test_not_exists', $this->mockClient); $this->assertEquals($database->exists(), false); }
/** * @param AbstractInfluxDbEvent $event */ private function testUdpConnection(AbstractInfluxDbEvent $event) { if (!$this->udpDatabase && ($event instanceof UdpEvent || $event instanceof DeferredUdpEvent)) { throw new \RuntimeException('No UDP connection available for database "' . $this->httpDatabase->getName() . '". ' . 'You must enable it on the configuration to use it.'); } }
/** * @see https://github.com/influxdata/influxdb-php/pull/36 */ public function testReservedNames() { $database = new Database('stats', $this->mockClient); // test handling of reserved keywords in database name $database->create(); $this->assertEquals('CREATE DATABASE IF NOT EXISTS "stats"', Client::$lastQuery); $database->listRetentionPolicies(); $this->assertEquals('SHOW RETENTION POLICIES ON "stats"', Client::$lastQuery); // test handling of reserved keywords in retention policy names $database->create($this->getTestRetentionPolicy('default')); $this->assertEquals('CREATE RETENTION POLICY "default" ON "stats" DURATION 1d REPLICATION 1 DEFAULT', Client::$lastQuery); // test handling of reserved keywords in measurement names $this->assertEquals($database->getQueryBuilder()->from('server')->getQuery(), 'SELECT * FROM "server"'); }
/** * Gets the result from the database (builds the query) * * @return ResultSet */ public function getResultSet() { return $this->db->query($this->parseQuery()); }
public function testWritePointsInASingleCall() { $point1 = new Point('cpu_load_short', 0.64, array('host' => 'server01', 'region' => 'us-west'), array('cpucount' => 10), 1435222310); $point2 = new Point('cpu_load_short', 0.84); $this->assertEquals(true, $this->db->writePoints(array($point1, $point2))); }