/** * @covers WindowsAzure\Table\Models\Filters\BinaryFilter::__construct * @covers WindowsAzure\Table\Models\Filters\BinaryFilter::getLeft */ public function testGetLeft() { // Setup $expected = null; $filter = new BinaryFilter($expected, null, null); // Assert $this->assertEquals($expected, $filter->getLeft()); }
public function testCheckBinaryFilter() { $filter = new BinaryFilter(null, null, null); $this->assertNotNull($filter, 'Default $filter'); $this->assertNull($filter->getLeft(), 'Default BinaryFilter->getFilter'); $this->assertNull($filter->getOperator(), 'Default BinaryFilter->getOperator'); $this->assertNull($filter->getRight(), 'Default BinaryFilter->getRight'); $left = new UnaryFilter(null, null); $operator = 'foo'; $right = new ConstantFilter(null, EdmType::STRING); $filter = new BinaryFilter($left, $operator, $right); $this->assertEquals($left, $filter->getLeft(), 'Set BinaryFilter->getLeft'); $this->assertEquals($operator, $filter->getOperator(), 'Set BinaryFilter->getOperator'); $this->assertEquals($right, $filter->getRight(), 'Set BinaryFilter->getRight'); // Now check the factory. $filter = Filter::applyAnd($left, $right); $this->assertEquals($left, $filter->getLeft(), 'and factory BinaryFilter->getLeft'); $this->assertEquals('and', $filter->getOperator(), 'and factory BinaryFilter->getOperator'); $this->assertEquals($right, $filter->getRight(), 'and factory BinaryFilter->getRight'); $filter = Filter::applyEq($left, $right); $this->assertEquals($left, $filter->getLeft(), 'eq factory BinaryFilter->getLeft'); $this->assertEquals('eq', $filter->getOperator(), 'eq factory BinaryFilter->getOperator'); $this->assertEquals($right, $filter->getRight(), 'eq factory BinaryFilter->getRight'); $filter = Filter::applyGe($left, $right); $this->assertEquals($left, $filter->getLeft(), 'ge factory BinaryFilter->getLeft'); $this->assertEquals('ge', $filter->getOperator(), 'ge factory BinaryFilter->getOperator'); $this->assertEquals($right, $filter->getRight(), 'ge factory BinaryFilter->getRight'); $filter = Filter::applyGt($left, $right); $this->assertEquals($left, $filter->getLeft(), 'gt factory BinaryFilter->getLeft'); $this->assertEquals('gt', $filter->getOperator(), 'gt factory BinaryFilter->getOperator'); $this->assertEquals($right, $filter->getRight(), 'gt factory BinaryFilter->getRight'); $filter = Filter::applyLe($left, $right); $this->assertEquals($left, $filter->getLeft(), 'le factory BinaryFilter->getLeft'); $this->assertEquals('le', $filter->getOperator(), 'le factory BinaryFilter->getOperator'); $this->assertEquals($right, $filter->getRight(), 'le factory BinaryFilter->getRight'); $filter = Filter::applyLt($left, $right); $this->assertEquals($left, $filter->getLeft(), 'lt factory BinaryFilter->getLeft'); $this->assertEquals('lt', $filter->getOperator(), 'lt factory BinaryFilter->getOperator'); $this->assertEquals($right, $filter->getRight(), 'lt factory BinaryFilter->getRight'); $filter = Filter::applyNe($left, $right); $this->assertEquals($left, $filter->getLeft(), 'ne factory BinaryFilter->getLeft'); $this->assertEquals('ne', $filter->getOperator(), 'ne factory BinaryFilter->getOperator'); $this->assertEquals($right, $filter->getRight(), 'ne factory BinaryFilter->getRight'); $filter = Filter::applyOr($left, $right); $this->assertEquals($left, $filter->getLeft(), 'or factory BinaryFilter->getLeft'); $this->assertEquals('or', $filter->getOperator(), 'or factory BinaryFilter->getOperator'); $this->assertEquals($right, $filter->getRight(), 'or factory BinaryFilter->getRight'); }