public function testCreateDataSourceWithAllOption() { $this->queryBuilder->expects($this->once())->method('getQuery')->will($this->returnValue($query = $this->createQueryMock())); $query->expects($this->once())->method('getIterator')->will($this->returnValue($iterator = $this->createIteratorMock())); $iterator->expects($this->once())->method('toArray')->will($this->returnValue($values = [new \stdClass()])); $dataSource = $this->builder->createDataSource(['all' => true]); $this->assertInstanceOf(ArrayDataSource::class, $dataSource); $this->assertSame($values, iterator_to_array($dataSource)); }
public function testNotBetween() { $this->queryBuilder->expects($this->exactly(3))->method('expr')->willReturnOnConsecutiveCalls($gteExpr = $this->createExprMock(), $lteExpr = $this->createExprMock(), $expr = $this->createExprMock()); $gteExpr->expects($this->once())->method('field')->with($this->identicalTo($value = 'property'))->will($this->returnSelf()); $gteExpr->expects($this->once())->method('lt')->with($this->identicalTo($x = 'from'))->will($this->returnSelf()); $lteExpr->expects($this->once())->method('field')->with($this->identicalTo($value))->will($this->returnSelf()); $lteExpr->expects($this->once())->method('gt')->with($this->identicalTo($y = 'to'))->will($this->returnSelf()); $expr->expects($this->exactly(2))->method('addOr')->withConsecutive([$gteExpr], [$lteExpr]); $this->assertSame($expr, $this->expressionBuilder->notBetween($value, $x, $y)); }