/**
  * @param array $rawData
  *
  * @return RuleVo
  */
 public function createRuleVo(array $rawData)
 {
     $this->testKeysExists($rawData, ['id', 'sortOrder', 'definitionUid', 'descending']);
     $vo = new RuleVo($rawData['id']);
     $vo->setOrder($rawData['sortOrder']);
     $vo->setDescending($rawData['descending']);
     $vo->setDefinitionUid($rawData['definitionUid']);
     return $vo;
 }
 public function testDefaultFieldQueryExtenderWithGroupExpressionCondition()
 {
     $defaultFieldQueryExtender = new OrderByFilterChain();
     $ruleVo = new RuleVo(1);
     $ruleVo->setDefinitionUid('s_articles::foo');
     $ruleVo->setDescending(true);
     $ruleVo->setOrder(0);
     $sortDefinition = new MockArticleNameDefinition(new ArticleTableLoader());
     $qb = $this->getQueryBuilder();
     $defaultFieldQueryExtender->extendQuery('product', $sortDefinition, $ruleVo, $qb);
     $this->assertContains('product_foo DESC', $qb->getSQL());
 }
 public function testDefaultFieldQueryExtender()
 {
     $extensionGateway = $this->createQueryExtensionGateway();
     $queryBuilder = $this->getQueryBuilder();
     $config = new SumOrderAmount(new OrderTableLoader());
     $rule = new RuleVo(1);
     $rule->setDefinitionUid($config->getUniqueIdentifier());
     $rule->setOrder(0);
     $beforeSql = $queryBuilder->getSQL();
     $extensionGateway->addRule($rule, $queryBuilder);
     $afterSql = $queryBuilder->getSQL();
     $this->assertNotEquals($beforeSql, $afterSql);
 }
 /**
  * triggers: Memory allocation error: 1038 Out of sort memory, consider increasing server sort buffer size.
  *
  * so no ->execute()
  */
 public function testIntegrationAll()
 {
     $qb = $this->getQueryBuilder();
     $qb->select('*');
     /** @var AbstractSortDefinition $definition */
     foreach ($this->definitionCollection as $definition) {
         $rule = new RuleVo(1);
         $rule->setOrder(0);
         $rule->setDescending(true);
         $rule->setDefinitionUid($definition->getUniqueIdentifier());
         $this->queryExtensionGateway->addRule($rule, $qb);
         $this->assertContains($definition->getFieldName(), $qb->getSQL());
         $this->assertContains($definition->getTableName(), $qb->getSql());
     }
 }