public function testAssemble() { $expression = new StringExpression(); $expression->setValue(1); $this->assertEquals('1', QueryAssembler::stringify($expression)); $expression->setValue('abc'); $this->assertEquals('"abc"', QueryAssembler::stringify($expression)); $expression->setValue('a"b"c'); $this->assertEquals('"a\\"b\\"c"', QueryAssembler::stringify($expression)); $expression->setValue('a"b"c'); $this->assertEquals("'a\"b\"c'", CqlAssembler::stringify($expression)); $expression->setValue("a'b'c"); $this->assertEquals("'a''b''c'", CqlAssembler::stringify($expression)); $expression->setValue("a''b''c"); $this->assertEquals("'a''''b''''c'", CqlAssembler::stringify($expression)); $expression->setValue("'a'b'c'"); $this->assertEquals("'''a''b''c'''", CqlAssembler::stringify($expression)); }
public function testGettersAndSetters() { $clause = new ValuesClause(); $field = new StringExpression(); $field->setValue('abc'); $null = new ValueExpression(); $this->assertFalse($clause->hasExpressions()); $clause->addExpression($field); $this->assertTrue($clause->hasExpressions()); $this->assertSame([$field], $clause->getExpressions()); $clause->clearExpressions(); $clause->setExpressions([$field, $null]); $this->assertTrue($clause->hasExpressions()); $clause->clearExpressions(); $this->assertFalse($clause->hasExpressions()); $this->setExpectedException("InvalidArgumentException"); $clause->setExpressions([$field, $null, 'abc']); }