@@ -17,22 +17,22 @@ discard block |
||
| 17 | 17 | protected function setUp() |
| 18 | 18 | { |
| 19 | 19 | $this->context = \TestHelperFrontend::getContext(); |
| 20 | - $this->object = new \Aimeos\Controller\Frontend\Product\Standard( $this->context ); |
|
| 20 | + $this->object = new \Aimeos\Controller\Frontend\Product\Standard($this->context); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
| 24 | 24 | protected function tearDown() |
| 25 | 25 | { |
| 26 | - unset( $this->object ); |
|
| 26 | + unset($this->object); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | public function testAggregate() |
| 31 | 31 | { |
| 32 | 32 | $filter = $this->object->createFilter(); |
| 33 | - $list = $this->object->aggregate( $filter, 'index.attribute.id' ); |
|
| 33 | + $list = $this->object->aggregate($filter, 'index.attribute.id'); |
|
| 34 | 34 | |
| 35 | - $this->assertGreaterThan( 0, count( $list ) ); |
|
| 35 | + $this->assertGreaterThan(0, count($list)); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | |
@@ -40,113 +40,113 @@ discard block |
||
| 40 | 40 | { |
| 41 | 41 | $filter = $this->object->createFilter(); |
| 42 | 42 | |
| 43 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 44 | - $this->assertEquals( [], $filter->getSortations() ); |
|
| 45 | - $this->assertEquals( 0, $filter->getSliceStart() ); |
|
| 46 | - $this->assertEquals( 100, $filter->getSliceSize() ); |
|
| 43 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 44 | + $this->assertEquals([], $filter->getSortations()); |
|
| 45 | + $this->assertEquals(0, $filter->getSliceStart()); |
|
| 46 | + $this->assertEquals(100, $filter->getSliceSize()); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | |
| 50 | 50 | public function testCreateFilterIgnoreDates() |
| 51 | 51 | { |
| 52 | - $this->context->getConfig()->set( 'controller/frontend/product/ignore-dates', true ); |
|
| 52 | + $this->context->getConfig()->set('controller/frontend/product/ignore-dates', true); |
|
| 53 | 53 | |
| 54 | 54 | $filter = $this->object->createFilter(); |
| 55 | 55 | |
| 56 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 56 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | |
| 60 | 60 | public function testAddFilterAttribute() |
| 61 | 61 | { |
| 62 | 62 | $filter = $this->object->createFilter(); |
| 63 | - $filter = $this->object->addFilterAttribute( $filter, array( 0, 1 ), [], [] ); |
|
| 63 | + $filter = $this->object->addFilterAttribute($filter, array(0, 1), [], []); |
|
| 64 | 64 | |
| 65 | 65 | $list = $filter->getConditions()->getExpressions(); |
| 66 | 66 | |
| 67 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
| 68 | - throw new \RuntimeException( 'Wrong expression' ); |
|
| 67 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
| 68 | + throw new \RuntimeException('Wrong expression'); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - $this->assertEquals( 'index.attributeaggregate([0,1])', $list[0]->getName() ); |
|
| 72 | - $this->assertEquals( 2, $list[0]->getValue() ); |
|
| 71 | + $this->assertEquals('index.attributeaggregate([0,1])', $list[0]->getName()); |
|
| 72 | + $this->assertEquals(2, $list[0]->getValue()); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
| 76 | 76 | public function testAddFilterAttributeOptions() |
| 77 | 77 | { |
| 78 | 78 | $filter = $this->object->createFilter(); |
| 79 | - $filter = $this->object->addFilterAttribute( $filter, [], array( 1 ), [] ); |
|
| 79 | + $filter = $this->object->addFilterAttribute($filter, [], array(1), []); |
|
| 80 | 80 | |
| 81 | 81 | $list = $filter->getConditions()->getExpressions(); |
| 82 | 82 | |
| 83 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
| 84 | - throw new \RuntimeException( 'Wrong expression' ); |
|
| 83 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
| 84 | + throw new \RuntimeException('Wrong expression'); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - $this->assertEquals( 'index.attributeaggregate([1])', $list[0]->getName() ); |
|
| 88 | - $this->assertEquals( 0, $list[0]->getValue() ); |
|
| 87 | + $this->assertEquals('index.attributeaggregate([1])', $list[0]->getName()); |
|
| 88 | + $this->assertEquals(0, $list[0]->getValue()); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | |
| 92 | 92 | public function testAddFilterAttributeOne() |
| 93 | 93 | { |
| 94 | 94 | $filter = $this->object->createFilter(); |
| 95 | - $filter = $this->object->addFilterAttribute( $filter, [], [], array( 'test' => array( 2 ) ) ); |
|
| 95 | + $filter = $this->object->addFilterAttribute($filter, [], [], array('test' => array(2))); |
|
| 96 | 96 | |
| 97 | 97 | $list = $filter->getConditions()->getExpressions(); |
| 98 | 98 | |
| 99 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
| 100 | - throw new \RuntimeException( 'Wrong expression' ); |
|
| 99 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
| 100 | + throw new \RuntimeException('Wrong expression'); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - $this->assertEquals( 'index.attributeaggregate([2])', $list[0]->getName() ); |
|
| 104 | - $this->assertEquals( 0, $list[0]->getValue() ); |
|
| 103 | + $this->assertEquals('index.attributeaggregate([2])', $list[0]->getName()); |
|
| 104 | + $this->assertEquals(0, $list[0]->getValue()); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | |
| 108 | 108 | public function testAddFilterCategory() |
| 109 | 109 | { |
| 110 | 110 | $context = \TestHelperFrontend::getContext(); |
| 111 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'catalog' ); |
|
| 111 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'catalog'); |
|
| 112 | 112 | |
| 113 | - $catId = $manager->findItem( 'root' )->getId(); |
|
| 113 | + $catId = $manager->findItem('root')->getId(); |
|
| 114 | 114 | $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST; |
| 115 | 115 | |
| 116 | 116 | $filter = $this->object->createFilter(); |
| 117 | - $filter = $this->object->addFilterCategory( $filter, $catId, $level ); |
|
| 117 | + $filter = $this->object->addFilterCategory($filter, $catId, $level); |
|
| 118 | 118 | |
| 119 | 119 | $list = $filter->getConditions()->getExpressions(); |
| 120 | 120 | |
| 121 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
| 122 | - throw new \RuntimeException( 'Wrong expression' ); |
|
| 121 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
| 122 | + throw new \RuntimeException('Wrong expression'); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - $this->assertEquals( 'index.catalog.id', $list[0]->getName() ); |
|
| 126 | - $this->assertEquals( 3, count( $list[0]->getValue() ) ); |
|
| 127 | - $this->assertEquals( [], $filter->getSortations() ); |
|
| 125 | + $this->assertEquals('index.catalog.id', $list[0]->getName()); |
|
| 126 | + $this->assertEquals(3, count($list[0]->getValue())); |
|
| 127 | + $this->assertEquals([], $filter->getSortations()); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | |
| 131 | 131 | public function testAddFilterText() |
| 132 | 132 | { |
| 133 | 133 | $filter = $this->object->createFilter(); |
| 134 | - $filter = $this->object->addFilterText( $filter, 'Espresso' ); |
|
| 134 | + $filter = $this->object->addFilterText($filter, 'Espresso'); |
|
| 135 | 135 | |
| 136 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 136 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 137 | 137 | |
| 138 | 138 | $list = $filter->getConditions()->getExpressions(); |
| 139 | 139 | |
| 140 | 140 | |
| 141 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
| 142 | - throw new \RuntimeException( 'Wrong expression' ); |
|
| 141 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
| 142 | + throw new \RuntimeException('Wrong expression'); |
|
| 143 | 143 | } |
| 144 | - $this->assertEquals( 'index.text.relevance("default","de","Espresso")', $list[0]->getName() ); |
|
| 145 | - $this->assertEquals( 0, $list[0]->getValue() ); |
|
| 144 | + $this->assertEquals('index.text.relevance("default","de","Espresso")', $list[0]->getName()); |
|
| 145 | + $this->assertEquals(0, $list[0]->getValue()); |
|
| 146 | 146 | |
| 147 | - $this->assertEquals( [], $filter->getSortations() ); |
|
| 148 | - $this->assertEquals( 0, $filter->getSliceStart() ); |
|
| 149 | - $this->assertEquals( 100, $filter->getSliceSize() ); |
|
| 147 | + $this->assertEquals([], $filter->getSortations()); |
|
| 148 | + $this->assertEquals(0, $filter->getSliceStart()); |
|
| 149 | + $this->assertEquals(100, $filter->getSliceSize()); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | |
@@ -155,162 +155,162 @@ discard block |
||
| 155 | 155 | $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE; |
| 156 | 156 | |
| 157 | 157 | $filter = $this->object->createFilter(); |
| 158 | - $filter = $this->object->addFilterCategory( $filter, 0, $level, 'relevance', '-', 'test' ); |
|
| 158 | + $filter = $this->object->addFilterCategory($filter, 0, $level, 'relevance', '-', 'test'); |
|
| 159 | 159 | |
| 160 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 160 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 161 | 161 | |
| 162 | 162 | $sort = $filter->getSortations(); |
| 163 | - if( ( $item = reset( $sort ) ) === false ) { |
|
| 164 | - throw new \RuntimeException( 'Sortation not set' ); |
|
| 163 | + if (($item = reset($sort)) === false) { |
|
| 164 | + throw new \RuntimeException('Sortation not set'); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - $this->assertEquals( 'sort:index.catalog.position("test",["0"])', $item->getName() ); |
|
| 168 | - $this->assertEquals( '-', $item->getOperator() ); |
|
| 167 | + $this->assertEquals('sort:index.catalog.position("test",["0"])', $item->getName()); |
|
| 168 | + $this->assertEquals('-', $item->getOperator()); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | |
| 172 | 172 | public function testCreateFilterSortRelevanceText() |
| 173 | 173 | { |
| 174 | - $filter = $this->object->createFilter( 'relevance', '-', 1, 2, 'test' ); |
|
| 175 | - $filter = $this->object->addFilterText( $filter, 'Espresso' ); |
|
| 174 | + $filter = $this->object->createFilter('relevance', '-', 1, 2, 'test'); |
|
| 175 | + $filter = $this->object->addFilterText($filter, 'Espresso'); |
|
| 176 | 176 | |
| 177 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 178 | - $this->assertEquals( [], $filter->getSortations() ); |
|
| 179 | - $this->assertEquals( 1, $filter->getSliceStart() ); |
|
| 180 | - $this->assertEquals( 2, $filter->getSliceSize() ); |
|
| 177 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 178 | + $this->assertEquals([], $filter->getSortations()); |
|
| 179 | + $this->assertEquals(1, $filter->getSliceStart()); |
|
| 180 | + $this->assertEquals(2, $filter->getSliceSize()); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | |
| 184 | 184 | public function testCreateFilterSortCode() |
| 185 | 185 | { |
| 186 | - $filter = $this->object->createFilter( 'code' ); |
|
| 186 | + $filter = $this->object->createFilter('code'); |
|
| 187 | 187 | |
| 188 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 188 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 189 | 189 | |
| 190 | 190 | $sort = $filter->getSortations(); |
| 191 | - if( ( $item = reset( $sort ) ) === false ) { |
|
| 192 | - throw new \RuntimeException( 'Sortation not set' ); |
|
| 191 | + if (($item = reset($sort)) === false) { |
|
| 192 | + throw new \RuntimeException('Sortation not set'); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - $this->assertEquals( 'product.code', $item->getName() ); |
|
| 195 | + $this->assertEquals('product.code', $item->getName()); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | |
| 199 | 199 | public function testCreateFilterSortName() |
| 200 | 200 | { |
| 201 | - $filter = $this->object->createFilter( 'name' ); |
|
| 201 | + $filter = $this->object->createFilter('name'); |
|
| 202 | 202 | |
| 203 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 203 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 204 | 204 | |
| 205 | 205 | $sort = $filter->getSortations(); |
| 206 | - if( ( $item = reset( $sort ) ) === false ) { |
|
| 207 | - throw new \RuntimeException( 'Sortation not set' ); |
|
| 206 | + if (($item = reset($sort)) === false) { |
|
| 207 | + throw new \RuntimeException('Sortation not set'); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - $this->assertEquals( 'sort:index.text.value("default","de","name")', $item->getName() ); |
|
| 210 | + $this->assertEquals('sort:index.text.value("default","de","name")', $item->getName()); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | |
| 214 | 214 | public function testCreateFilterSortPrice() |
| 215 | 215 | { |
| 216 | - $filter = $this->object->createFilter( 'price' ); |
|
| 216 | + $filter = $this->object->createFilter('price'); |
|
| 217 | 217 | |
| 218 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 218 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 219 | 219 | |
| 220 | 220 | $sort = $filter->getSortations(); |
| 221 | - if( ( $item = reset( $sort ) ) === false ) { |
|
| 222 | - throw new \RuntimeException( 'Sortation not set' ); |
|
| 221 | + if (($item = reset($sort)) === false) { |
|
| 222 | + throw new \RuntimeException('Sortation not set'); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - $this->assertStringStartsWith( 'sort:index.price.value("default","EUR","default")', $item->getName() ); |
|
| 225 | + $this->assertStringStartsWith('sort:index.price.value("default","EUR","default")', $item->getName()); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | |
| 229 | 229 | public function testCreateFilterSortInvalid() |
| 230 | 230 | { |
| 231 | - $filter = $this->object->createFilter( '', 'failure' ); |
|
| 231 | + $filter = $this->object->createFilter('', 'failure'); |
|
| 232 | 232 | |
| 233 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
| 234 | - $this->assertEquals( [], $filter->getSortations() ); |
|
| 233 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
| 234 | + $this->assertEquals([], $filter->getSortations()); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | |
| 238 | 238 | public function testGetItem() |
| 239 | 239 | { |
| 240 | 240 | $context = \TestHelperFrontend::getContext(); |
| 241 | - $id = \Aimeos\MShop\Factory::createManager( $context, 'product' )->findItem( 'CNC' )->getId(); |
|
| 241 | + $id = \Aimeos\MShop\Factory::createManager($context, 'product')->findItem('CNC')->getId(); |
|
| 242 | 242 | |
| 243 | - $result = $this->object->getItem( $id ); |
|
| 243 | + $result = $this->object->getItem($id); |
|
| 244 | 244 | |
| 245 | - $this->assertInstanceOf( '\Aimeos\MShop\Product\Item\Iface', $result ); |
|
| 246 | - $this->assertGreaterThan( 0, $result->getPropertyItems() ); |
|
| 247 | - $this->assertGreaterThan( 0, $result->getRefItems( 'attribute' ) ); |
|
| 248 | - $this->assertGreaterThan( 0, $result->getRefItems( 'media' ) ); |
|
| 249 | - $this->assertGreaterThan( 0, $result->getRefItems( 'price' ) ); |
|
| 250 | - $this->assertGreaterThan( 0, $result->getRefItems( 'product' ) ); |
|
| 251 | - $this->assertGreaterThan( 0, $result->getRefItems( 'text' ) ); |
|
| 245 | + $this->assertInstanceOf('\Aimeos\MShop\Product\Item\Iface', $result); |
|
| 246 | + $this->assertGreaterThan(0, $result->getPropertyItems()); |
|
| 247 | + $this->assertGreaterThan(0, $result->getRefItems('attribute')); |
|
| 248 | + $this->assertGreaterThan(0, $result->getRefItems('media')); |
|
| 249 | + $this->assertGreaterThan(0, $result->getRefItems('price')); |
|
| 250 | + $this->assertGreaterThan(0, $result->getRefItems('product')); |
|
| 251 | + $this->assertGreaterThan(0, $result->getRefItems('text')); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | |
| 255 | 255 | public function testGetItems() |
| 256 | 256 | { |
| 257 | 257 | $context = \TestHelperFrontend::getContext(); |
| 258 | - $context->getConfig()->set( 'controller/frontend/product/ignore-dates', true ); |
|
| 258 | + $context->getConfig()->set('controller/frontend/product/ignore-dates', true); |
|
| 259 | 259 | |
| 260 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
| 260 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
| 261 | 261 | |
| 262 | 262 | $search = $manager->createSearch(); |
| 263 | - $search->setConditions( $search->compare( '==', 'product.code', array( 'CNC', 'CNE' ) ) ); |
|
| 263 | + $search->setConditions($search->compare('==', 'product.code', array('CNC', 'CNE'))); |
|
| 264 | 264 | |
| 265 | 265 | $ids = []; |
| 266 | - foreach( $manager->searchItems( $search ) as $productItem ) { |
|
| 266 | + foreach ($manager->searchItems($search) as $productItem) { |
|
| 267 | 267 | $ids[] = $productItem->getId(); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | |
| 271 | - $result = $this->object->getItems( $ids ); |
|
| 271 | + $result = $this->object->getItems($ids); |
|
| 272 | 272 | |
| 273 | - $this->assertEquals( 2, count( $result ) ); |
|
| 273 | + $this->assertEquals(2, count($result)); |
|
| 274 | 274 | |
| 275 | - foreach( $result as $productItem ) { |
|
| 276 | - $this->assertInstanceOf( '\Aimeos\MShop\Product\Item\Iface', $productItem ); |
|
| 275 | + foreach ($result as $productItem) { |
|
| 276 | + $this->assertInstanceOf('\Aimeos\MShop\Product\Item\Iface', $productItem); |
|
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | |
| 281 | 281 | public function testSearchItemsCategory() |
| 282 | 282 | { |
| 283 | - $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
| 283 | + $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
| 284 | 284 | $search = $catalogManager->createSearch(); |
| 285 | 285 | |
| 286 | - $search->setConditions( $search->compare( '==', 'catalog.code', 'new' ) ); |
|
| 287 | - $search->setSlice( 0, 1 ); |
|
| 288 | - $items = $catalogManager->searchItems( $search ); |
|
| 286 | + $search->setConditions($search->compare('==', 'catalog.code', 'new')); |
|
| 287 | + $search->setSlice(0, 1); |
|
| 288 | + $items = $catalogManager->searchItems($search); |
|
| 289 | 289 | |
| 290 | - if( ( $item = reset( $items ) ) === false ) { |
|
| 291 | - throw new \RuntimeException( 'Product item not found' ); |
|
| 290 | + if (($item = reset($items)) === false) { |
|
| 291 | + throw new \RuntimeException('Product item not found'); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - $filter = $this->object->createFilter( 'position', '+', 1, 1 ); |
|
| 295 | - $filter = $this->object->addFilterCategory( $filter, $item->getId() ); |
|
| 294 | + $filter = $this->object->createFilter('position', '+', 1, 1); |
|
| 295 | + $filter = $this->object->addFilterCategory($filter, $item->getId()); |
|
| 296 | 296 | |
| 297 | 297 | $total = 0; |
| 298 | - $results = $this->object->searchItems( $filter, [], $total ); |
|
| 298 | + $results = $this->object->searchItems($filter, [], $total); |
|
| 299 | 299 | |
| 300 | - $this->assertEquals( 3, $total ); |
|
| 301 | - $this->assertEquals( 1, count( $results ) ); |
|
| 300 | + $this->assertEquals(3, $total); |
|
| 301 | + $this->assertEquals(1, count($results)); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | |
| 305 | 305 | public function testSearchItemsText() |
| 306 | 306 | { |
| 307 | - $filter = $this->object->createFilter( 'relevance', '+', 0, 1, 'unittype13' ); |
|
| 308 | - $filter = $this->object->addFilterText( $filter, 'Expresso', 'relevance', '+', 'unittype13' ); |
|
| 307 | + $filter = $this->object->createFilter('relevance', '+', 0, 1, 'unittype13'); |
|
| 308 | + $filter = $this->object->addFilterText($filter, 'Expresso', 'relevance', '+', 'unittype13'); |
|
| 309 | 309 | |
| 310 | 310 | $total = 0; |
| 311 | - $results = $this->object->searchItems( $filter, [], $total ); |
|
| 311 | + $results = $this->object->searchItems($filter, [], $total); |
|
| 312 | 312 | |
| 313 | - $this->assertEquals( 2, $total ); |
|
| 314 | - $this->assertEquals( 1, count( $results ) ); |
|
| 313 | + $this->assertEquals(2, $total); |
|
| 314 | + $this->assertEquals(1, count($results)); |
|
| 315 | 315 | } |
| 316 | 316 | } |
@@ -31,42 +31,42 @@ discard block |
||
| 31 | 31 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
| 32 | 32 | * @since 2017.03 |
| 33 | 33 | */ |
| 34 | - public function addFilterAttribute( \Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds ) |
|
| 34 | + public function addFilterAttribute(\Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds) |
|
| 35 | 35 | { |
| 36 | - if( !empty( $attrIds ) ) |
|
| 36 | + if (!empty($attrIds)) |
|
| 37 | 37 | { |
| 38 | - $attrIds = $this->validateIds( $attrIds ); |
|
| 38 | + $attrIds = $this->validateIds($attrIds); |
|
| 39 | 39 | |
| 40 | - $func = $filter->createFunction( 'index.attributeaggregate', array( $attrIds ) ); |
|
| 40 | + $func = $filter->createFunction('index.attributeaggregate', array($attrIds)); |
|
| 41 | 41 | $expr = array( |
| 42 | - $filter->compare( '==', $func, count( $attrIds ) ), |
|
| 42 | + $filter->compare('==', $func, count($attrIds)), |
|
| 43 | 43 | $filter->getConditions(), |
| 44 | 44 | ); |
| 45 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
| 45 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if( !empty( $optIds ) ) |
|
| 48 | + if (!empty($optIds)) |
|
| 49 | 49 | { |
| 50 | - $optIds = $this->validateIds( $optIds ); |
|
| 50 | + $optIds = $this->validateIds($optIds); |
|
| 51 | 51 | |
| 52 | - $func = $filter->createFunction( 'index.attributeaggregate', array( $optIds ) ); |
|
| 52 | + $func = $filter->createFunction('index.attributeaggregate', array($optIds)); |
|
| 53 | 53 | $expr = array( |
| 54 | - $filter->compare( '>', $func, 0 ), |
|
| 54 | + $filter->compare('>', $func, 0), |
|
| 55 | 55 | $filter->getConditions(), |
| 56 | 56 | ); |
| 57 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
| 57 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - foreach( $oneIds as $type => $list ) |
|
| 60 | + foreach ($oneIds as $type => $list) |
|
| 61 | 61 | { |
| 62 | - if( ( $list = $this->validateIds( (array) $list ) ) !== [] ) |
|
| 62 | + if (($list = $this->validateIds((array) $list)) !== []) |
|
| 63 | 63 | { |
| 64 | - $func = $filter->createFunction( 'index.attributeaggregate', array( $list ) ); |
|
| 64 | + $func = $filter->createFunction('index.attributeaggregate', array($list)); |
|
| 65 | 65 | $expr = array( |
| 66 | - $filter->compare( '>', $func, 0 ), |
|
| 66 | + $filter->compare('>', $func, 0), |
|
| 67 | 67 | $filter->getConditions(), |
| 68 | 68 | ); |
| 69 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
| 69 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
@@ -86,38 +86,38 @@ discard block |
||
| 86 | 86 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
| 87 | 87 | * @since 2017.03 |
| 88 | 88 | */ |
| 89 | - public function addFilterCategory( \Aimeos\MW\Criteria\Iface $filter, $catId, |
|
| 90 | - $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default' ) |
|
| 89 | + public function addFilterCategory(\Aimeos\MW\Criteria\Iface $filter, $catId, |
|
| 90 | + $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default') |
|
| 91 | 91 | { |
| 92 | - $catIds = ( !is_array( $catId ) ? explode( ',', $catId ) : $catId ); |
|
| 92 | + $catIds = (!is_array($catId) ? explode(',', $catId) : $catId); |
|
| 93 | 93 | |
| 94 | - if( $level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ) |
|
| 94 | + if ($level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE) |
|
| 95 | 95 | { |
| 96 | 96 | $list = []; |
| 97 | - $cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'catalog' ); |
|
| 97 | + $cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'catalog'); |
|
| 98 | 98 | |
| 99 | - foreach( $catIds as $catId ) |
|
| 99 | + foreach ($catIds as $catId) |
|
| 100 | 100 | { |
| 101 | - $tree = $cntl->getCatalogTree( $catId, [], $level ); |
|
| 102 | - $list = array_merge( $list, $this->getCatalogIdsFromTree( $tree ) ); |
|
| 101 | + $tree = $cntl->getCatalogTree($catId, [], $level); |
|
| 102 | + $list = array_merge($list, $this->getCatalogIdsFromTree($tree)); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | $catIds = $list; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - $expr = array( $filter->compare( '==', 'index.catalog.id', array_unique( $catIds ) ) ); |
|
| 108 | + $expr = array($filter->compare('==', 'index.catalog.id', array_unique($catIds))); |
|
| 109 | 109 | $expr[] = $filter->getConditions(); |
| 110 | 110 | |
| 111 | - if( $sort === 'relevance' ) |
|
| 111 | + if ($sort === 'relevance') |
|
| 112 | 112 | { |
| 113 | - $cmpfunc = $filter->createFunction( 'index.catalog.position', array( $listtype, $catIds ) ); |
|
| 114 | - $expr[] = $filter->compare( '>=', $cmpfunc, 0 ); |
|
| 113 | + $cmpfunc = $filter->createFunction('index.catalog.position', array($listtype, $catIds)); |
|
| 114 | + $expr[] = $filter->compare('>=', $cmpfunc, 0); |
|
| 115 | 115 | |
| 116 | - $sortfunc = $filter->createFunction( 'sort:index.catalog.position', array( $listtype, $catIds ) ); |
|
| 117 | - $filter->setSortations( array( $filter->sort( $direction, $sortfunc ) ) ); |
|
| 116 | + $sortfunc = $filter->createFunction('sort:index.catalog.position', array($listtype, $catIds)); |
|
| 117 | + $filter->setSortations(array($filter->sort($direction, $sortfunc))); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
| 120 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
| 121 | 121 | |
| 122 | 122 | return $filter; |
| 123 | 123 | } |
@@ -134,13 +134,13 @@ discard block |
||
| 134 | 134 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
| 135 | 135 | * @since 2017.03 |
| 136 | 136 | */ |
| 137 | - public function addFilterText( \Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default' ) |
|
| 137 | + public function addFilterText(\Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default') |
|
| 138 | 138 | { |
| 139 | 139 | $langid = $this->getContext()->getLocale()->getLanguageId(); |
| 140 | - $cmpfunc = $filter->createFunction( 'index.text.relevance', array( $listtype, $langid, $input ) ); |
|
| 141 | - $expr = array( $filter->compare( '>', $cmpfunc, 0 ), $filter->getConditions() ); |
|
| 140 | + $cmpfunc = $filter->createFunction('index.text.relevance', array($listtype, $langid, $input)); |
|
| 141 | + $expr = array($filter->compare('>', $cmpfunc, 0), $filter->getConditions()); |
|
| 142 | 142 | |
| 143 | - return $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
| 143 | + return $filter->setConditions($filter->combine('&&', $expr)); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | |
@@ -152,9 +152,9 @@ discard block |
||
| 152 | 152 | * @return array Associative list of key values as key and the product count for this key as value |
| 153 | 153 | * @since 2017.03 |
| 154 | 154 | */ |
| 155 | - public function aggregate( \Aimeos\MW\Criteria\Iface $filter, $key ) |
|
| 155 | + public function aggregate(\Aimeos\MW\Criteria\Iface $filter, $key) |
|
| 156 | 156 | { |
| 157 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->aggregate( $filter, $key ); |
|
| 157 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->aggregate($filter, $key); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | |
@@ -169,58 +169,58 @@ discard block |
||
| 169 | 169 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
| 170 | 170 | * @since 2017.03 |
| 171 | 171 | */ |
| 172 | - public function createFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' ) |
|
| 172 | + public function createFilter($sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default') |
|
| 173 | 173 | { |
| 174 | 174 | $sortations = []; |
| 175 | 175 | $context = $this->getContext(); |
| 176 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'index' ); |
|
| 176 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'index'); |
|
| 177 | 177 | |
| 178 | 178 | |
| 179 | - if( $context->getConfig()->get( 'controller/frontend/product/ignore-dates', false ) ) |
|
| 179 | + if ($context->getConfig()->get('controller/frontend/product/ignore-dates', false)) |
|
| 180 | 180 | { |
| 181 | 181 | $search = $manager->createSearch(); |
| 182 | - $search->setConditions( $search->compare( '>', 'product.status', 0 ) ); |
|
| 182 | + $search->setConditions($search->compare('>', 'product.status', 0)); |
|
| 183 | 183 | } |
| 184 | 184 | else |
| 185 | 185 | { |
| 186 | - $search = $manager->createSearch( true ); |
|
| 186 | + $search = $manager->createSearch(true); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | |
| 190 | - $expr = array( $search->compare( '!=', 'index.catalog.id', null ) ); |
|
| 190 | + $expr = array($search->compare('!=', 'index.catalog.id', null)); |
|
| 191 | 191 | |
| 192 | - switch( $sort ) |
|
| 192 | + switch ($sort) |
|
| 193 | 193 | { |
| 194 | 194 | case 'code': |
| 195 | - $sortations[] = $search->sort( $direction, 'product.code' ); |
|
| 195 | + $sortations[] = $search->sort($direction, 'product.code'); |
|
| 196 | 196 | break; |
| 197 | 197 | |
| 198 | 198 | case 'name': |
| 199 | 199 | $langid = $context->getLocale()->getLanguageId(); |
| 200 | 200 | |
| 201 | - $cmpfunc = $search->createFunction( 'index.text.value', array( $listtype, $langid, 'name', 'product' ) ); |
|
| 202 | - $expr[] = $search->compare( '>=', $cmpfunc, '' ); |
|
| 201 | + $cmpfunc = $search->createFunction('index.text.value', array($listtype, $langid, 'name', 'product')); |
|
| 202 | + $expr[] = $search->compare('>=', $cmpfunc, ''); |
|
| 203 | 203 | |
| 204 | - $sortfunc = $search->createFunction( 'sort:index.text.value', array( $listtype, $langid, 'name' ) ); |
|
| 205 | - $sortations[] = $search->sort( $direction, $sortfunc ); |
|
| 204 | + $sortfunc = $search->createFunction('sort:index.text.value', array($listtype, $langid, 'name')); |
|
| 205 | + $sortations[] = $search->sort($direction, $sortfunc); |
|
| 206 | 206 | break; |
| 207 | 207 | |
| 208 | 208 | case 'price': |
| 209 | 209 | $currencyid = $context->getLocale()->getCurrencyId(); |
| 210 | 210 | |
| 211 | - $cmpfunc = $search->createFunction( 'index.price.value', array( $listtype, $currencyid, 'default' ) ); |
|
| 212 | - $expr[] = $search->compare( '>=', $cmpfunc, '0.00' ); |
|
| 211 | + $cmpfunc = $search->createFunction('index.price.value', array($listtype, $currencyid, 'default')); |
|
| 212 | + $expr[] = $search->compare('>=', $cmpfunc, '0.00'); |
|
| 213 | 213 | |
| 214 | - $sortfunc = $search->createFunction( 'sort:index.price.value', array( $listtype, $currencyid, 'default' ) ); |
|
| 215 | - $sortations[] = $search->sort( $direction, $sortfunc ); |
|
| 214 | + $sortfunc = $search->createFunction('sort:index.price.value', array($listtype, $currencyid, 'default')); |
|
| 215 | + $sortations[] = $search->sort($direction, $sortfunc); |
|
| 216 | 216 | break; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | $expr[] = $search->getConditions(); |
| 220 | 220 | |
| 221 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 222 | - $search->setSortations( $sortations ); |
|
| 223 | - $search->setSlice( $start, $size ); |
|
| 221 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 222 | + $search->setSortations($sortations); |
|
| 223 | + $search->setSlice($start, $size); |
|
| 224 | 224 | |
| 225 | 225 | return $search; |
| 226 | 226 | } |
@@ -234,15 +234,15 @@ discard block |
||
| 234 | 234 | * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items |
| 235 | 235 | * @since 2017.03 |
| 236 | 236 | */ |
| 237 | - public function getItem( $productId, array $domains = array( 'attribute', 'media', 'price', 'product', 'product/property', 'text' ) ) |
|
| 237 | + public function getItem($productId, array $domains = array('attribute', 'media', 'price', 'product', 'product/property', 'text')) |
|
| 238 | 238 | { |
| 239 | - $items = $this->getItems( [$productId], $domains ); |
|
| 239 | + $items = $this->getItems([$productId], $domains); |
|
| 240 | 240 | |
| 241 | - if( ( $item = reset( $items ) ) !== false ) { |
|
| 241 | + if (($item = reset($items)) !== false) { |
|
| 242 | 242 | return $item; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Product item with ID "%1$s" not found', $productId ) ); |
|
| 245 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Product item with ID "%1$s" not found', $productId)); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
@@ -254,10 +254,10 @@ discard block |
||
| 254 | 254 | * @return \Aimeos\MShop\Product\Item\Iface[] Associative list of product IDs as keys and product items as values |
| 255 | 255 | * @since 2017.03 |
| 256 | 256 | */ |
| 257 | - public function getItems( array $productIds, array $domains = array( 'media', 'price', 'text' ) ) |
|
| 257 | + public function getItems(array $productIds, array $domains = array('media', 'price', 'text')) |
|
| 258 | 258 | { |
| 259 | 259 | $context = $this->getContext(); |
| 260 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
| 260 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
| 261 | 261 | |
| 262 | 262 | /** controller/frontend/order/ignore-dates |
| 263 | 263 | * Ignore start and end dates of products |
@@ -271,24 +271,24 @@ discard block |
||
| 271 | 271 | * @since 2017.08 |
| 272 | 272 | * @category Developer |
| 273 | 273 | */ |
| 274 | - if( $context->getConfig()->get( 'controller/frontend/product/ignore-dates', false ) ) |
|
| 274 | + if ($context->getConfig()->get('controller/frontend/product/ignore-dates', false)) |
|
| 275 | 275 | { |
| 276 | 276 | $search = $manager->createSearch(); |
| 277 | - $search->setConditions( $search->compare( '>', 'product.status', 0 ) ); |
|
| 277 | + $search->setConditions($search->compare('>', 'product.status', 0)); |
|
| 278 | 278 | } |
| 279 | 279 | else |
| 280 | 280 | { |
| 281 | - $search = $manager->createSearch( true ); |
|
| 281 | + $search = $manager->createSearch(true); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | $expr = array( |
| 285 | - $search->compare( '==', 'product.id', $productIds ), |
|
| 285 | + $search->compare('==', 'product.id', $productIds), |
|
| 286 | 286 | $search->getConditions(), |
| 287 | 287 | ); |
| 288 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 289 | - $search->setSlice( 0, count( $productIds ) ); |
|
| 288 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 289 | + $search->setSlice(0, count($productIds)); |
|
| 290 | 290 | |
| 291 | - return $manager->searchItems( $search, $domains ); |
|
| 291 | + return $manager->searchItems($search, $domains); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | |
@@ -301,9 +301,9 @@ discard block |
||
| 301 | 301 | * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface |
| 302 | 302 | * @since 2017.03 |
| 303 | 303 | */ |
| 304 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ) |
|
| 304 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null) |
|
| 305 | 305 | { |
| 306 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->searchItems( $filter, $domains, $total ); |
|
| 306 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->searchItems($filter, $domains, $total); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | |
@@ -313,12 +313,12 @@ discard block |
||
| 313 | 313 | * @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item with children |
| 314 | 314 | * @return array List of catalog IDs |
| 315 | 315 | */ |
| 316 | - protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item ) |
|
| 316 | + protected function getCatalogIdsFromTree(\Aimeos\MShop\Catalog\Item\Iface $item) |
|
| 317 | 317 | { |
| 318 | - $list = array( $item->getId() ); |
|
| 318 | + $list = array($item->getId()); |
|
| 319 | 319 | |
| 320 | - foreach( $item->getChildren() as $child ) { |
|
| 321 | - $list = array_merge( $list, $this->getCatalogIdsFromTree( $child ) ); |
|
| 320 | + foreach ($item->getChildren() as $child) { |
|
| 321 | + $list = array_merge($list, $this->getCatalogIdsFromTree($child)); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | return $list; |
@@ -331,13 +331,13 @@ discard block |
||
| 331 | 331 | * @param array $ids List of IDs to validate |
| 332 | 332 | * @return array List of validated IDs |
| 333 | 333 | */ |
| 334 | - protected function validateIds( array $ids ) |
|
| 334 | + protected function validateIds(array $ids) |
|
| 335 | 335 | { |
| 336 | 336 | $list = []; |
| 337 | 337 | |
| 338 | - foreach( $ids as $id ) |
|
| 338 | + foreach ($ids as $id) |
|
| 339 | 339 | { |
| 340 | - if( $id != '' ) { |
|
| 340 | + if ($id != '') { |
|
| 341 | 341 | $list[] = (int) $id; |
| 342 | 342 | } |
| 343 | 343 | } |
@@ -180,8 +180,7 @@ discard block |
||
| 180 | 180 | { |
| 181 | 181 | $search = $manager->createSearch(); |
| 182 | 182 | $search->setConditions( $search->compare( '>', 'product.status', 0 ) ); |
| 183 | - } |
|
| 184 | - else |
|
| 183 | + } else |
|
| 185 | 184 | { |
| 186 | 185 | $search = $manager->createSearch( true ); |
| 187 | 186 | } |
@@ -275,8 +274,7 @@ discard block |
||
| 275 | 274 | { |
| 276 | 275 | $search = $manager->createSearch(); |
| 277 | 276 | $search->setConditions( $search->compare( '>', 'product.status', 0 ) ); |
| 278 | - } |
|
| 279 | - else |
|
| 277 | + } else |
|
| 280 | 278 | { |
| 281 | 279 | $search = $manager->createSearch( true ); |
| 282 | 280 | } |