/**
  * Composite Cassandra types (list, map, set, tuple, and UDT) to be used by
  * data providers
  */
 public function compositeCassandraTypes()
 {
     $collectionType = Type::collection(Type::varchar());
     $setType = Type::set(Type::varchar());
     $mapType = Type::map(Type::varchar(), Type::int());
     $tupleType = Type::tuple(Type::varchar(), Type::int(), Type::bigint());
     $userType = Type::userType("a", Type::varchar(), "b", Type::int(), "c", Type::bigint());
     $userType = $userType->withName(self::userTypeString($userType));
     return array(array($collectionType, array($collectionType->create("a", "b", "c"), $collectionType->create("d", "e", "f"), $collectionType->create("x", "y", "z"))), array($setType, array($setType->create("a", "b", "c"), $setType->create("d", "e", "f"), $setType->create("x", "y", "z"))), array($mapType, array($mapType->create("a", 1, "b", 2, "c", 3), $mapType->create("d", 4, "e", 5, "f", 6), $mapType->create("x", 7, "y", 8, "z", 9))), array($tupleType, array($tupleType->create("a", 1, new Bigint(2)), $tupleType->create("b", 3, new Bigint(4)), $tupleType->create("c", 5, new Bigint(6)))), array($userType, array($userType->create("a", "x", "b", 1, "c", new Bigint(2)), $userType->create("a", "y", "b", 3, "c", new Bigint(4)), $userType->create("a", "z", "b", 5, "c", new Bigint(6)))));
 }
Exemplo n.º 2
0
 public function notEqualTypes()
 {
     $setType = Type::set(Type::int());
     return array(array(Type::collection(Type::int())->create(), Type::collection(Type::varchar())->create()), array(Type::collection(Type::int())->create(1, 2, 3), Type::collection(Type::int())->create(4, 5, 6)), array(Type::collection(Type::int())->create(1, 2, 3), Type::collection(Type::int())->create(1)), array(Type::collection(Type::varchar())->create('a', 'b', 'c'), Type::collection(Type::varchar())->create('a', 'b', 'd')), array(Type::collection($setType)->create($setType->create(1, 2, 3)), Type::collection($setType)->create($setType->create(4, 5, 6))));
 }
 /**
  * Partial user type
  *
  * This test will ensure that partial user types return the correct value.
  *
  * @test
  * @ticket PHP-58
  */
 public function testPartial()
 {
     $userType = Type::userType("a", Type::int(), "b", Type::varchar(), "c", Type::bigint());
     $userType = $userType->withName(self::userTypeString($userType));
     $this->createUserType($userType);
     $user = $userType->create();
     $user->set("a", 99);
     $this->createTableInsertAndVerifyValueByIndex($userType, $user);
     $user = $userType->create();
     $user->set("b", "abc");
     $this->createTableInsertAndVerifyValueByIndex($userType, $user);
     $user = $userType->create();
     $user->set("c", new Bigint("999999999999"));
     $this->createTableInsertAndVerifyValueByIndex($userType, $user);
 }
Exemplo n.º 4
0
 /**
  * Invalid datatypes for tuples.
  *
  * This test will ensure that an exception will occur when an invalid
  * datatype is used inside a tuple; issues from the server.
  *
  * @test
  * @ticket PHP-58
  * @expectedException \Cassandra\Exception\InvalidQueryException
  */
 public function testInvalidType()
 {
     $validType = Type::tuple(Type::int());
     $invalidType = Type::tuple(Type::varchar());
     $tableName = $this->createTable($validType);
     $options = new ExecutionOptions(array('arguments' => array("key", $invalidType->create("value"))));
     $this->insertValue($tableName, $options);
 }
 /**
  * Scalar Cassandra types to be used by data providers
  */
 public function scalarCassandraTypes()
 {
     return array(array(Type::ascii(), array("a", "b", "c")), array(Type::bigint(), array(new Bigint("1"), new Bigint("2"), new Bigint("3"))), array(Type::blob(), array(new Blob("x"), new Blob("y"), new Blob("z"))), array(Type::boolean(), array(true, false, true, false)), array(Type::date(), array(new Date(), new Date(0), new Date(-86400), new Date(86400))), array(Type::decimal(), array(new Decimal(1.1), new Decimal(2.2), new Decimal(3.3))), array(Type::double(), array(1.1, 2.2, 3.3, 4.4)), array(Type::float(), array(new Float(1.0), new Float(2.2), new Float(2.2))), array(Type::inet(), array(new Inet("127.0.0.1"), new Inet("127.0.0.2"), new Inet("127.0.0.3"))), array(Type::smallint(), array(Smallint::min(), Smallint::max(), new Smallint(0), new Smallint(74))), array(Type::text(), array("a", "b", "c", "x", "y", "z")), array(Type::time(), array(new Time(), new Time(0), new Time(1234567890))), array(Type::tinyint(), array(Tinyint::min(), Tinyint::max(), new Tinyint(0), new Tinyint(37))), array(Type::timestamp(), array(new Timestamp(123), new Timestamp(456), new Timestamp(789))), array(Type::timeuuid(), array(new Timeuuid(0), new Timeuuid(1), new Timeuuid(2))), array(Type::uuid(), array(new Uuid("03398c99-c635-4fad-b30a-3b2c49f785c2"), new Uuid("03398c99-c635-4fad-b30a-3b2c49f785c3"), new Uuid("03398c99-c635-4fad-b30a-3b2c49f785c4"))), array(Type::varchar(), array("a", "b", "c", "x", "y", "z")), array(Type::varint(), array(new Varint(1), new Varint(2), new Varint(3))));
 }
Exemplo n.º 6
0
 public function notEqualTypes()
 {
     $setType = Type::set(Type::int());
     return array(array(Type::userType('a', Type::int(), 'b', Type::varchar(), 'c', Type::varint())->create(), Type::userType('a', Type::int(), 'b', Type::varchar(), 'c', Type::bigint())->create()), array(Type::userType('a', Type::int(), 'b', Type::varchar(), 'c', Type::bigint())->create(), Type::userType('x', Type::int(), 'y', Type::varchar(), 'z', Type::bigint())->create()), array(Type::userType('a', Type::int(), 'b', Type::varchar(), 'c', Type::bigint())->create('a', 1, 'b', 'x', 'c', new Bigint(99)), Type::userType('a', Type::int(), 'b', Type::varchar(), 'c', Type::bigint())->create('a', 2, 'b', 'y', 'c', new Bigint(999))), array(Type::userType('a', $setType, 'b', Type::varchar())->create('a', $setType->create(1, 2, 3), 'b', 'x'), Type::userType('a', $setType, 'b', Type::varchar())->create('a', $setType->create(4, 5, 6), 'b', 'x')));
 }
Exemplo n.º 7
0
 public function notEqualTypes()
 {
     $setType = Type::set(Type::int());
     return array(array(Type::tuple(Type::int(), Type::varchar(), Type::varint())->create(), Type::tuple(Type::int(), Type::varchar(), Type::bigint())->create()), array(Type::tuple(Type::int(), Type::varchar(), Type::bigint())->create(1, 'a', new Bigint(99)), Type::tuple(Type::int(), Type::varchar(), Type::bigint())->create(2, 'b', new Bigint(99))), array(Type::tuple($setType, Type::varchar())->create($setType->create(1, 2, 3), 'a'), Type::tuple($setType, Type::varchar())->create($setType->create(4, 5, 6), 'a')));
 }