Author: Elliot Levin (elliotlevin@hotmail.com)
 public function visitOrderBy(Segments\OrderBy $segment)
 {
     foreach ($segment->getOrderings() as $ordering) {
         $this->parameters->addId($ordering->getIsAscendingId(), ParameterHasher::valueType());
     }
     return parent::visitOrderBy($segment);
 }
Example #2
0
 public function addIdParameter($id)
 {
     $namedParameter = $this->createNamedParameter();
     $this->parameters->addId($id, ParameterHasher::valueType(), $namedParameter);
     return $namedParameter;
 }
 public function visitRange(Segments\Range $segment)
 {
     $this->parameters->addId($segment->getStartId(), ParameterHasher::valueType());
     $this->parameters->addId($segment->getAmountId(), ParameterHasher::valueType());
     return parent::visitRange($segment);
 }
 /**
  * Adds the necessary expression(s) to the supplied collection.
  *
  * @param IFunction $function
  * @param O\Expression $expression
  * @param Parameters\ParameterCollection $parameters
  *
  * @return void
  */
 public function parameterize(IFunction $function, O\Expression $expression, Parameters\ParameterCollection $parameters)
 {
     /** @var O\InvocationExpression $expression */
     $this->addParameter($parameters, $function, $expression->getValue(), ParameterHasher::functionSignature());
 }
 public function testCollectionSuppliesCorrectParameterHasToExpressionParameter()
 {
     $this->collection->addExpression(O\Expression::value('val-test'), $hasher = ParameterHasher::valueType());
     $this->assertSame($hasher, $this->collection->getParameters()[0]->getHasher());
 }
 protected function addParameter(Parameters\ParameterCollection $parameters, IFunction $function, O\Expression $expression, Parameters\IParameterHasher $hasher = null)
 {
     $parameters->add(new StructuralExpressionParameter($expression, $hasher ?: Parameters\ParameterHasher::valueType(), $function));
 }
Example #7
0
 public function testCompiledRequestQueryHasher()
 {
     $hasher = ParameterHasher::compiledRequestQuery();
     $configurationMock = $this->getMockBuilder('Pinq\\Providers\\DSL\\QueryCompilerConfiguration')->setMethods(['getCompiledRequestQueryHash'])->disableOriginalConstructor()->getMockForAbstractClass();
     $configurationMock->expects($this->once())->method('getCompiledRequestQueryHash')->will($this->returnValue('123456789'));
     /** @var $provider \Pinq\Providers\DSL\QueryProvider|\PHPUnit_Framework_MockObject_MockObject */
     $provider = $this->getMockForAbstractClass('Pinq\\Providers\\DSL\\QueryProvider', [new Queries\SourceInfo(''), $configurationMock]);
     $queryable = $provider->createQueryable();
     $this->assertSame($hasher->hash($queryable), '123456789');
 }