function it_applies_a_sort_on_product_completeness(ProductDatasource $datasource, $repository, ProductQueryBuilderInterface $pqb, QueryBuilder $qb) { $datasource->getQueryBuilder()->willReturn($qb); $repository->getProductQueryBuilder($qb)->willReturn($pqb); $pqb->addFieldSorter('completeness', 'ASC')->shouldBeCalled(); $this->apply($datasource, 'completeness', 'ASC'); }
function it_applies_a_sort_on_in_group_products(ProductDatasource $datasource, $repository, ProductQueryBuilderInterface $pqb, QueryBuilder $qb, $params) { $datasource->getQueryBuilder()->willReturn($qb); $params->get('currentGroup', null)->willReturn(12); $repository->getProductQueryBuilder($qb)->willReturn($pqb); $pqb->addFieldSorter('in_group_12', 'ASC')->shouldBeCalled(); $this->apply($datasource, 'in_group', 'ASC'); }
function it_applies_a_sort_on_product_sku(ProductDatasource $datasource, $repository, ProductQueryBuilderInterface $pqb, QueryBuilder $qb, CustomAttributeRepository $attributeRepository, AbstractAttribute $sku) { // TODO : how to mock the following magic method ? $attributeRepository->findOneByCode('sku')->willReturn($sku); $sku->getCode()->willReturn('sku'); $sku->__toString()->willReturn('sku'); $datasource->getQueryBuilder()->willReturn($qb); $repository->getProductQueryBuilder($qb)->willReturn($pqb); $pqb->addAttributeSorter($sku, 'ASC')->shouldBeCalled(); $this->apply($datasource, $sku, 'ASC'); }