InfluxDB\Test\AbstractTest::setUp PHP Method

setUp() public method

public setUp ( )
    public function setUp()
    {
        $this->mockClient = $this->getMockBuilder('\\InfluxDB\\Client')->disableOriginalConstructor()->getMock();
        $this->resultData = file_get_contents(dirname(__FILE__) . '/json/result.example.json');
        $this->mockClient->expects($this->any())->method('getBaseURI')->will($this->returnValue($this->equalTo('http://localhost:8086')));
        $this->mockClient->expects($this->any())->method('query')->will($this->returnCallback(function ($db, $query) {
            Client::$lastQuery = $query;
            return new ResultSet($this->resultData);
        }));
        $this->mockClient->expects($this->any())->method('write')->will($this->returnValue(true));
        $httpMockClient = new GuzzleDriver($this->buildHttpMockClient(''));
        // make sure the client has a valid driver
        $this->mockClient->expects($this->any())->method('getDriver')->will($this->returnValue($httpMockClient));
        $this->database = new Database('influx_test_db', $this->mockClient);
    }

Usage Example

Example #1
0
 public function setUp()
 {
     parent::setUp();
     $this->resultData = file_get_contents(dirname(__FILE__) . '/result.example.json');
     $this->mockClient->expects($this->any())->method('listDatabases')->will($this->returnValue(array('test123', 'test')));
     $this->dataToInsert = file_get_contents(dirname(__FILE__) . '/input.example.json');
 }
All Usage Examples Of InfluxDB\Test\AbstractTest::setUp