Cassandra\TimestampIntegrationTest::testBatchStatement PHP Method

testBatchStatement() public method

This test will ensure that the PHP driver supports timestamps using batch statements; client, server, and forced (option and using) timestamps are executed.
public testBatchStatement ( )
    public function testBatchStatement()
    {
        // Create the batch statement
        $batch = new BatchStatement(\Cassandra::BATCH_UNLOGGED);
        $simple = new SimpleStatement($this->insertQuery);
        $prepare = $this->session->prepare($this->insertQuery);
        // Simple statement
        $batch->add($simple, array(0, 1));
        // Prepared statement
        $batch->add($prepare, array("key" => 1, "value_int" => 2));
        // Forced timestamp (simple)
        $query = "{$this->insertQuery} USING TIMESTAMP 90";
        $simple = new SimpleStatement($query);
        $batch->add($simple, array(2, 3));
        // Insert the batch and assert the values
        $this->insert($this->session, $batch, null, null, 11111);
        $this->assert(0, 11111);
        $this->assert(1, 11111);
        $this->assert(2, 90);
        // Using timestamp generator (client); upsert will occur
        $now = $this->now();
        sleep(1);
        $this->insert($this->clientSideTimestampSession, $batch);
        $this->assert(0, $now, false);
        $this->assert(1, $now, false);
        $this->assert(2, 90);
        // Using timestamp generator (server); upsert will occur
        $serverMow = $this->serverNow();
        sleep(1);
        $this->insert($this->session, $batch);
        $this->assert(0, $serverMow, false);
        $this->assert(1, $serverMow, false);
        $this->assert(2, 90);
    }