1@cassandra-version-3.10
2Feature: Duration
3
4  PHP Driver supports the `Duration` datatype
5
6  Background:
7    Given a running Cassandra cluster
8
9  Scenario: Use the duration type
10    Given the following schema:
11      """cql
12      CREATE KEYSPACE simplex WITH replication = {
13        'class': 'SimpleStrategy',
14        'replication_factor': 1
15      };
16      USE simplex;
17      CREATE TABLE duration (k text PRIMARY KEY, d duration);
18      """
19    And the following example:
20      """
21      <?php
22      $cluster   = Cassandra::cluster()->build();
23      $session   = $cluster->connect("simplex");
24
25      $durations = array(
26          array('two_days', new Cassandra\Duration(2, 0, 0)),
27          array('twelve_hours', new Cassandra\Duration(0, 12, 0)),
28          array('three_seconds', new Cassandra\Duration(0, 0, 3 * (1000 ** 3))),
29          array('two_days_twelve_hours_and_three_seconds', new Cassandra\Duration(2, 12, 3 * (1000 ** 3)))
30      );
31
32      foreach ($durations as $duration) {
33          $options = array('arguments' => $duration);
34          $session->execute("INSERT INTO duration (k, d) VALUES (?, ?)", $options);
35      }
36
37      $rows = $session->execute("SELECT * FROM duration");
38
39      foreach ($rows as $row) {
40        echo "{$row['k']}: {$row['d']}" . PHP_EOL;
41      }
42      """
43    When it is executed
44    Then its output should contain these lines in any order:
45      """
46      twelve_hours: 0mo12d0ns
47      three_seconds: 0mo0d3000000000ns
48      two_days_twelve_hours_and_three_seconds: 2mo12d3000000000ns
49      two_days: 2mo0d0ns
50      """
51
52