@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param string|null $name Name of the controller implementaton (default: "Standard") |
30 | 30 | * @return \Aimeos\Controller\Frontend\Common\Iface Controller object |
31 | 31 | */ |
32 | - public static function createController( \Aimeos\MShop\Context\Item\Iface $context, $name = null ) |
|
32 | + public static function createController(\Aimeos\MShop\Context\Item\Iface $context, $name = null) |
|
33 | 33 | { |
34 | 34 | /** controller/frontend/order/name |
35 | 35 | * Class name of the used order frontend controller implementation |
@@ -64,19 +64,19 @@ discard block |
||
64 | 64 | * @since 2014.03 |
65 | 65 | * @category Developer |
66 | 66 | */ |
67 | - if( $name === null ) { |
|
68 | - $name = $context->getConfig()->get( 'controller/frontend/order/name', 'Standard' ); |
|
67 | + if ($name === null) { |
|
68 | + $name = $context->getConfig()->get('controller/frontend/order/name', 'Standard'); |
|
69 | 69 | } |
70 | 70 | |
71 | - if( ctype_alnum( $name ) === false ) { |
|
72 | - $classname = is_string( $name ) ? '\\Aimeos\\Controller\\Frontend\\Order\\' . $name : '<not a string>'; |
|
73 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
71 | + if (ctype_alnum($name) === false) { |
|
72 | + $classname = is_string($name) ? '\\Aimeos\\Controller\\Frontend\\Order\\' . $name : '<not a string>'; |
|
73 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | $iface = '\\Aimeos\\Controller\\Frontend\\Order\\Iface'; |
77 | 77 | $classname = '\\Aimeos\\Controller\\Frontend\\Order\\' . $name; |
78 | 78 | |
79 | - $manager = self::createControllerBase( $context, $classname, $iface ); |
|
79 | + $manager = self::createControllerBase($context, $classname, $iface); |
|
80 | 80 | |
81 | 81 | /** controller/frontend/order/decorators/excludes |
82 | 82 | * Excludes decorators added by the "common" option from the order frontend controllers |
@@ -152,6 +152,6 @@ discard block |
||
152 | 152 | * @see controller/frontend/order/decorators/excludes |
153 | 153 | * @see controller/frontend/order/decorators/global |
154 | 154 | */ |
155 | - return self::addControllerDecorators( $context, $manager, 'order' ); |
|
155 | + return self::addControllerDecorators($context, $manager, 'order'); |
|
156 | 156 | } |
157 | 157 | } |
@@ -17,33 +17,33 @@ |
||
17 | 17 | protected function setUp() |
18 | 18 | { |
19 | 19 | $context = \TestHelperFrontend::getContext(); |
20 | - $cntl = new \Aimeos\Controller\Frontend\Catalog\Standard( $context ); |
|
20 | + $cntl = new \Aimeos\Controller\Frontend\Catalog\Standard($context); |
|
21 | 21 | |
22 | - $this->object = new \Aimeos\Controller\Frontend\Common\Decorator\Example( $cntl, $context ); |
|
22 | + $this->object = new \Aimeos\Controller\Frontend\Common\Decorator\Example($cntl, $context); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | |
26 | 26 | public function testCall() |
27 | 27 | { |
28 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Manager\Iface', $this->object->createManager( 'product' ) ); |
|
28 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Manager\Iface', $this->object->createManager('product')); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | |
32 | 32 | public function testCallInvalid() |
33 | 33 | { |
34 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Exception' ); |
|
34 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Exception'); |
|
35 | 35 | $this->object->invalidMethod(); |
36 | 36 | } |
37 | 37 | |
38 | 38 | |
39 | 39 | public function testGetContext() |
40 | 40 | { |
41 | - $this->assertInstanceOf( '\Aimeos\MShop\Context\Item\Iface', $this->object->getContext() ); |
|
41 | + $this->assertInstanceOf('\Aimeos\MShop\Context\Item\Iface', $this->object->getContext()); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | 45 | public function testGetController() |
46 | 46 | { |
47 | - $this->assertInstanceOf( '\Aimeos\Controller\Frontend\Iface', $this->object->getController() ); |
|
47 | + $this->assertInstanceOf('\Aimeos\Controller\Frontend\Iface', $this->object->getController()); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | \ No newline at end of file |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @param \Aimeos\MShop\Context\Item\Iface $context Common MShop context object |
30 | 30 | */ |
31 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
|
31 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context) |
|
32 | 32 | { |
33 | 33 | $this->context = $context; |
34 | 34 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param array $param List of method parameter |
42 | 42 | * @return boolean Returns always false |
43 | 43 | */ |
44 | - public function __call( $name, array $param ) |
|
44 | + public function __call($name, array $param) |
|
45 | 45 | { |
46 | 46 | return false; |
47 | 47 | } |
@@ -4,7 +4,7 @@ |
||
4 | 4 | 'frontend' => array( |
5 | 5 | 'basket' => array( |
6 | 6 | 'decorators' => array( |
7 | - 'local' => array( 'Category', 'Stock' ), |
|
7 | + 'local' => array('Category', 'Stock'), |
|
8 | 8 | ), |
9 | 9 | ), |
10 | 10 | ), |
@@ -17,92 +17,92 @@ |
||
17 | 17 | { |
18 | 18 | public function testCreateController() |
19 | 19 | { |
20 | - $controller = \Aimeos\Controller\Frontend\Factory::createController( \TestHelperFrontend::getContext(), 'basket' ); |
|
21 | - $this->assertInstanceOf( '\\Aimeos\\Controller\\Frontend\\Iface', $controller ); |
|
20 | + $controller = \Aimeos\Controller\Frontend\Factory::createController(\TestHelperFrontend::getContext(), 'basket'); |
|
21 | + $this->assertInstanceOf('\\Aimeos\\Controller\\Frontend\\Iface', $controller); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | |
25 | 25 | public function testCreateControllerEmpty() |
26 | 26 | { |
27 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' ); |
|
28 | - \Aimeos\Controller\Frontend\Factory::createController( \TestHelperFrontend::getContext(), "\t\n" ); |
|
27 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception'); |
|
28 | + \Aimeos\Controller\Frontend\Factory::createController(\TestHelperFrontend::getContext(), "\t\n"); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | |
32 | 32 | public function testCreateControllerInvalidName() |
33 | 33 | { |
34 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' ); |
|
35 | - \Aimeos\Controller\Frontend\Factory::createController( \TestHelperFrontend::getContext(), '%^' ); |
|
34 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception'); |
|
35 | + \Aimeos\Controller\Frontend\Factory::createController(\TestHelperFrontend::getContext(), '%^'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
39 | 39 | public function testCreateControllerNotExisting() |
40 | 40 | { |
41 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' ); |
|
42 | - \Aimeos\Controller\Frontend\Factory::createController( \TestHelperFrontend::getContext(), 'notexist' ); |
|
41 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception'); |
|
42 | + \Aimeos\Controller\Frontend\Factory::createController(\TestHelperFrontend::getContext(), 'notexist'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
46 | 46 | public function testCreateSubControllerNotExisting() |
47 | 47 | { |
48 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' ); |
|
49 | - \Aimeos\Controller\Frontend\Factory::createController( \TestHelperFrontend::getContext(), 'basket/notexist' ); |
|
48 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception'); |
|
49 | + \Aimeos\Controller\Frontend\Factory::createController(\TestHelperFrontend::getContext(), 'basket/notexist'); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
53 | 53 | public function testClear() |
54 | 54 | { |
55 | - $cache = \Aimeos\Controller\Frontend\Factory::setCache( true ); |
|
55 | + $cache = \Aimeos\Controller\Frontend\Factory::setCache(true); |
|
56 | 56 | |
57 | 57 | $context = \TestHelperFrontend::getContext(); |
58 | 58 | |
59 | - $controller1 = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' ); |
|
59 | + $controller1 = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); |
|
60 | 60 | \Aimeos\Controller\Frontend\Factory::clear(); |
61 | - $controller2 = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' ); |
|
61 | + $controller2 = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); |
|
62 | 62 | |
63 | - \Aimeos\Controller\Frontend\Factory::setCache( $cache ); |
|
63 | + \Aimeos\Controller\Frontend\Factory::setCache($cache); |
|
64 | 64 | |
65 | - $this->assertNotSame( $controller1, $controller2 ); |
|
65 | + $this->assertNotSame($controller1, $controller2); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
69 | 69 | public function testClearSite() |
70 | 70 | { |
71 | - $cache = \Aimeos\Controller\Frontend\Factory::setCache( true ); |
|
71 | + $cache = \Aimeos\Controller\Frontend\Factory::setCache(true); |
|
72 | 72 | |
73 | 73 | $context = \TestHelperFrontend::getContext(); |
74 | 74 | |
75 | - $basket1 = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' ); |
|
76 | - $catalog1 = \Aimeos\Controller\Frontend\Factory::createController( $context, 'catalog' ); |
|
77 | - \Aimeos\Controller\Frontend\Factory::clear( (string) $context ); |
|
75 | + $basket1 = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); |
|
76 | + $catalog1 = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); |
|
77 | + \Aimeos\Controller\Frontend\Factory::clear((string) $context); |
|
78 | 78 | |
79 | - $basket2 = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' ); |
|
80 | - $catalog2 = \Aimeos\Controller\Frontend\Factory::createController( $context, 'catalog' ); |
|
79 | + $basket2 = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); |
|
80 | + $catalog2 = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); |
|
81 | 81 | |
82 | - \Aimeos\Controller\Frontend\Factory::setCache( $cache ); |
|
82 | + \Aimeos\Controller\Frontend\Factory::setCache($cache); |
|
83 | 83 | |
84 | - $this->assertNotSame( $basket1, $basket2 ); |
|
85 | - $this->assertNotSame( $catalog1, $catalog2 ); |
|
84 | + $this->assertNotSame($basket1, $basket2); |
|
85 | + $this->assertNotSame($catalog1, $catalog2); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | |
89 | 89 | public function testClearSpecific() |
90 | 90 | { |
91 | - $cache = \Aimeos\Controller\Frontend\Factory::setCache( true ); |
|
91 | + $cache = \Aimeos\Controller\Frontend\Factory::setCache(true); |
|
92 | 92 | |
93 | 93 | $context = \TestHelperFrontend::getContext(); |
94 | 94 | |
95 | - $basket1 = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' ); |
|
96 | - $catalog1 = \Aimeos\Controller\Frontend\Factory::createController( $context, 'catalog' ); |
|
97 | - \Aimeos\Controller\Frontend\Factory::clear( (string) $context, 'basket' ); |
|
95 | + $basket1 = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); |
|
96 | + $catalog1 = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); |
|
97 | + \Aimeos\Controller\Frontend\Factory::clear((string) $context, 'basket'); |
|
98 | 98 | |
99 | - $basket2 = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' ); |
|
100 | - $catalog2 = \Aimeos\Controller\Frontend\Factory::createController( $context, 'catalog' ); |
|
99 | + $basket2 = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); |
|
100 | + $catalog2 = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); |
|
101 | 101 | |
102 | - \Aimeos\Controller\Frontend\Factory::setCache( $cache ); |
|
102 | + \Aimeos\Controller\Frontend\Factory::setCache($cache); |
|
103 | 103 | |
104 | - $this->assertNotSame( $basket1, $basket2 ); |
|
105 | - $this->assertSame( $catalog1, $catalog2 ); |
|
104 | + $this->assertNotSame($basket1, $basket2); |
|
105 | + $this->assertSame($catalog1, $catalog2); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | } |
109 | 109 | \ No newline at end of file |
@@ -12,35 +12,35 @@ |
||
12 | 12 | protected function setUp() |
13 | 13 | { |
14 | 14 | $this->context = \TestHelperFrontend::getContext(); |
15 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
16 | - $this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Category( $object, $this->context ); |
|
15 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
16 | + $this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Category($object, $this->context); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | |
20 | 20 | protected function tearDown() |
21 | 21 | { |
22 | 22 | $this->object->clear(); |
23 | - $this->context->getSession()->set( 'aimeos', array() ); |
|
23 | + $this->context->getSession()->set('aimeos', array()); |
|
24 | 24 | |
25 | - unset( $this->object ); |
|
25 | + unset($this->object); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
29 | 29 | public function testAddProductWithCategory() |
30 | 30 | { |
31 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' ); |
|
32 | - $item = $manager->findItem( 'CNE' ); |
|
31 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'product'); |
|
32 | + $item = $manager->findItem('CNE'); |
|
33 | 33 | |
34 | - $this->object->addProduct( $item->getId(), 5 ); |
|
34 | + $this->object->addProduct($item->getId(), 5); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
38 | 38 | public function testAddProductNoCategory() |
39 | 39 | { |
40 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' ); |
|
41 | - $item = $manager->findItem( 'ABCD' ); |
|
40 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'product'); |
|
41 | + $item = $manager->findItem('ABCD'); |
|
42 | 42 | |
43 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Basket\Exception' ); |
|
44 | - $this->object->addProduct( $item->getId(), 5 ); |
|
43 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Basket\Exception'); |
|
44 | + $this->object->addProduct($item->getId(), 5); |
|
45 | 45 | } |
46 | 46 | } |
@@ -12,132 +12,132 @@ discard block |
||
12 | 12 | protected function setUp() |
13 | 13 | { |
14 | 14 | $this->context = \TestHelperFrontend::getContext(); |
15 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
16 | - $this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Stock( $object, $this->context ); |
|
15 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
16 | + $this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Stock($object, $this->context); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | |
20 | 20 | protected function tearDown() |
21 | 21 | { |
22 | 22 | $this->object->clear(); |
23 | - $this->context->getSession()->set( 'aimeos', array() ); |
|
23 | + $this->context->getSession()->set('aimeos', array()); |
|
24 | 24 | |
25 | - unset( $this->object ); |
|
25 | + unset($this->object); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
29 | 29 | public function testAddProductNotEnoughStockException() |
30 | 30 | { |
31 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
31 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
32 | 32 | |
33 | 33 | $search = $productManager->createSearch(); |
34 | - $search->setConditions( $search->compare( '==', 'product.code', 'IJKL' ) ); |
|
34 | + $search->setConditions($search->compare('==', 'product.code', 'IJKL')); |
|
35 | 35 | |
36 | - $items = $productManager->searchItems( $search ); |
|
36 | + $items = $productManager->searchItems($search); |
|
37 | 37 | |
38 | - if( ( $item = reset( $items ) ) === false ) { |
|
39 | - throw new \Exception( 'Product not found' ); |
|
38 | + if (($item = reset($items)) === false) { |
|
39 | + throw new \Exception('Product not found'); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | try |
43 | 43 | { |
44 | - $this->object->addProduct( $item->getId(), 5, array(), array(), array(), array(), array(), 'unit_warehouse3' ); |
|
45 | - throw new \Exception( 'Expected exception not thrown' ); |
|
44 | + $this->object->addProduct($item->getId(), 5, array(), array(), array(), array(), array(), 'unit_warehouse3'); |
|
45 | + throw new \Exception('Expected exception not thrown'); |
|
46 | 46 | } |
47 | - catch( \Aimeos\Controller\Frontend\Basket\Exception $e ) |
|
47 | + catch (\Aimeos\Controller\Frontend\Basket\Exception $e) |
|
48 | 48 | { |
49 | - $item = $this->object->get()->getProduct( 0 ); |
|
50 | - $this->assertEquals( 3, $item->getQuantity() ); |
|
49 | + $item = $this->object->get()->getProduct(0); |
|
50 | + $this->assertEquals(3, $item->getQuantity()); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | 55 | public function testAddProductNoStockException() |
56 | 56 | { |
57 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
57 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
58 | 58 | |
59 | 59 | $search = $productManager->createSearch(); |
60 | - $search->setConditions( $search->compare( '==', 'product.code', 'EFGH' ) ); |
|
60 | + $search->setConditions($search->compare('==', 'product.code', 'EFGH')); |
|
61 | 61 | |
62 | - $items = $productManager->searchItems( $search ); |
|
62 | + $items = $productManager->searchItems($search); |
|
63 | 63 | |
64 | - if( ( $item = reset( $items ) ) === false ) { |
|
65 | - throw new \Exception( 'Product not found' ); |
|
64 | + if (($item = reset($items)) === false) { |
|
65 | + throw new \Exception('Product not found'); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | try |
69 | 69 | { |
70 | - $this->object->addProduct( $item->getId(), 5, array(), array(), array(), array(), array(), 'unit_warehouse2' ); |
|
71 | - throw new \Exception( 'Expected exception not thrown' ); |
|
70 | + $this->object->addProduct($item->getId(), 5, array(), array(), array(), array(), array(), 'unit_warehouse2'); |
|
71 | + throw new \Exception('Expected exception not thrown'); |
|
72 | 72 | } |
73 | - catch( \Aimeos\Controller\Frontend\Basket\Exception $e ) |
|
73 | + catch (\Aimeos\Controller\Frontend\Basket\Exception $e) |
|
74 | 74 | { |
75 | - $this->assertEquals( array(), $this->object->get()->getProducts() ); |
|
75 | + $this->assertEquals(array(), $this->object->get()->getProducts()); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | 79 | |
80 | 80 | public function testAddProductNoStockRequired() |
81 | 81 | { |
82 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
82 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
83 | 83 | |
84 | 84 | $search = $productManager->createSearch(); |
85 | - $search->setConditions( $search->compare( '==', 'product.code', 'IJKL' ) ); |
|
85 | + $search->setConditions($search->compare('==', 'product.code', 'IJKL')); |
|
86 | 86 | |
87 | - $items = $productManager->searchItems( $search ); |
|
87 | + $items = $productManager->searchItems($search); |
|
88 | 88 | |
89 | - if( ( $item = reset( $items ) ) === false ) { |
|
90 | - throw new \Exception( 'Product not found' ); |
|
89 | + if (($item = reset($items)) === false) { |
|
90 | + throw new \Exception('Product not found'); |
|
91 | 91 | } |
92 | 92 | |
93 | - $this->object->addProduct( $item->getId(), 5, array( 'stock' => false ) ); |
|
93 | + $this->object->addProduct($item->getId(), 5, array('stock' => false)); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | |
97 | 97 | public function testAddProductNoStockItem() |
98 | 98 | { |
99 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
99 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
100 | 100 | |
101 | 101 | $search = $productManager->createSearch(); |
102 | - $search->setConditions( $search->compare( '==', 'product.code', 'QRST' ) ); |
|
102 | + $search->setConditions($search->compare('==', 'product.code', 'QRST')); |
|
103 | 103 | |
104 | - $items = $productManager->searchItems( $search ); |
|
104 | + $items = $productManager->searchItems($search); |
|
105 | 105 | |
106 | - if( ( $item = reset( $items ) ) === false ) { |
|
107 | - throw new \Exception( 'Product not found' ); |
|
106 | + if (($item = reset($items)) === false) { |
|
107 | + throw new \Exception('Product not found'); |
|
108 | 108 | } |
109 | 109 | |
110 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
111 | - $this->object->addProduct( $item->getId(), 1 ); |
|
110 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
111 | + $this->object->addProduct($item->getId(), 1); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | |
115 | 115 | public function testEditProductNotEnoughStock() |
116 | 116 | { |
117 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
117 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
118 | 118 | $search = $productManager->createSearch(); |
119 | - $search->setConditions( $search->compare( '==', 'product.code', 'IJKL' ) ); |
|
120 | - $items = $productManager->searchItems( $search ); |
|
119 | + $search->setConditions($search->compare('==', 'product.code', 'IJKL')); |
|
120 | + $items = $productManager->searchItems($search); |
|
121 | 121 | |
122 | - if( ( $item = reset( $items ) ) === false ) { |
|
123 | - throw new \Exception( 'Product not found' ); |
|
122 | + if (($item = reset($items)) === false) { |
|
123 | + throw new \Exception('Product not found'); |
|
124 | 124 | } |
125 | 125 | |
126 | - $this->object->addProduct( $item->getId(), 2, array(), array(), array(), array(), array(), 'unit_warehouse3' ); |
|
126 | + $this->object->addProduct($item->getId(), 2, array(), array(), array(), array(), array(), 'unit_warehouse3'); |
|
127 | 127 | |
128 | - $item = $this->object->get()->getProduct( 0 ); |
|
129 | - $this->assertEquals( 2, $item->getQuantity() ); |
|
128 | + $item = $this->object->get()->getProduct(0); |
|
129 | + $this->assertEquals(2, $item->getQuantity()); |
|
130 | 130 | |
131 | 131 | try |
132 | 132 | { |
133 | - $this->object->editProduct( 0, 5 ); |
|
134 | - throw new \Exception( 'Expected exception not thrown' ); |
|
133 | + $this->object->editProduct(0, 5); |
|
134 | + throw new \Exception('Expected exception not thrown'); |
|
135 | 135 | } |
136 | - catch( \Aimeos\Controller\Frontend\Basket\Exception $e ) |
|
136 | + catch (\Aimeos\Controller\Frontend\Basket\Exception $e) |
|
137 | 137 | { |
138 | - $item = $this->object->get()->getProduct( 0 ); |
|
139 | - $this->assertEquals( 3, $item->getQuantity() ); |
|
140 | - $this->assertEquals( 'IJKL', $item->getProductCode() ); |
|
138 | + $item = $this->object->get()->getProduct(0); |
|
139 | + $this->assertEquals(3, $item->getQuantity()); |
|
140 | + $this->assertEquals('IJKL', $item->getProductCode()); |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
@@ -146,58 +146,58 @@ discard block |
||
146 | 146 | { |
147 | 147 | $context = \TestHelperFrontend::getContext(); |
148 | 148 | |
149 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
149 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
150 | 150 | $search = $productManager->createSearch(); |
151 | - $search->setConditions( $search->compare( '==', 'product.code', 'IJKL' ) ); |
|
152 | - $items = $productManager->searchItems( $search ); |
|
151 | + $search->setConditions($search->compare('==', 'product.code', 'IJKL')); |
|
152 | + $items = $productManager->searchItems($search); |
|
153 | 153 | |
154 | - if( ( $item = reset( $items ) ) === false ) { |
|
155 | - throw new \Exception( 'Product not found' ); |
|
154 | + if (($item = reset($items)) === false) { |
|
155 | + throw new \Exception('Product not found'); |
|
156 | 156 | } |
157 | 157 | |
158 | - $orderProductManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' ); |
|
158 | + $orderProductManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product'); |
|
159 | 159 | $orderProductItem = $orderProductManager->createItem(); |
160 | - $orderProductItem->copyFrom( $item ); |
|
161 | - $orderProductItem->setQuantity( 2 ); |
|
162 | - $orderProductItem->setWarehouseCode( 'unit_warehouse3' ); |
|
160 | + $orderProductItem->copyFrom($item); |
|
161 | + $orderProductItem->setQuantity(2); |
|
162 | + $orderProductItem->setWarehouseCode('unit_warehouse3'); |
|
163 | 163 | |
164 | - $pos = $this->object->get()->addProduct( $orderProductItem, 1 ); |
|
164 | + $pos = $this->object->get()->addProduct($orderProductItem, 1); |
|
165 | 165 | |
166 | - $item = $this->object->get()->getProduct( $pos ); |
|
167 | - $this->assertEquals( 2, $item->getQuantity() ); |
|
166 | + $item = $this->object->get()->getProduct($pos); |
|
167 | + $this->assertEquals(2, $item->getQuantity()); |
|
168 | 168 | |
169 | 169 | try |
170 | 170 | { |
171 | - $this->object->editProduct( $pos, 5 ); |
|
172 | - throw new \Exception( 'Expected exception not thrown' ); |
|
171 | + $this->object->editProduct($pos, 5); |
|
172 | + throw new \Exception('Expected exception not thrown'); |
|
173 | 173 | } |
174 | - catch( \Aimeos\Controller\Frontend\Basket\Exception $e ) |
|
174 | + catch (\Aimeos\Controller\Frontend\Basket\Exception $e) |
|
175 | 175 | { |
176 | - $this->assertEquals( 3, $this->object->get()->getProduct( $pos )->getQuantity() ); |
|
176 | + $this->assertEquals(3, $this->object->get()->getProduct($pos)->getQuantity()); |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
180 | 180 | |
181 | 181 | public function testEditProductStockNotChecked() |
182 | 182 | { |
183 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
183 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
184 | 184 | $search = $productManager->createSearch(); |
185 | - $search->setConditions( $search->compare( '==', 'product.code', 'IJKL' ) ); |
|
186 | - $items = $productManager->searchItems( $search ); |
|
185 | + $search->setConditions($search->compare('==', 'product.code', 'IJKL')); |
|
186 | + $items = $productManager->searchItems($search); |
|
187 | 187 | |
188 | - if( ( $item = reset( $items ) ) === false ) { |
|
189 | - throw new \Exception( 'Product not found' ); |
|
188 | + if (($item = reset($items)) === false) { |
|
189 | + throw new \Exception('Product not found'); |
|
190 | 190 | } |
191 | 191 | |
192 | - $this->object->addProduct( $item->getId(), 2, array(), array(), array(), array(), array(), 'unit_warehouse3' ); |
|
192 | + $this->object->addProduct($item->getId(), 2, array(), array(), array(), array(), array(), 'unit_warehouse3'); |
|
193 | 193 | |
194 | - $item = $this->object->get()->getProduct( 0 ); |
|
195 | - $this->assertEquals( 2, $item->getQuantity() ); |
|
194 | + $item = $this->object->get()->getProduct(0); |
|
195 | + $this->assertEquals(2, $item->getQuantity()); |
|
196 | 196 | |
197 | - $this->object->editProduct( 0, 5, array( 'stock' => false ) ); |
|
197 | + $this->object->editProduct(0, 5, array('stock' => false)); |
|
198 | 198 | |
199 | - $item = $this->object->get()->getProduct( 0 ); |
|
200 | - $this->assertEquals( 5, $item->getQuantity() ); |
|
201 | - $this->assertEquals( 'IJKL', $item->getProductCode() ); |
|
199 | + $item = $this->object->get()->getProduct(0); |
|
200 | + $this->assertEquals(5, $item->getQuantity()); |
|
201 | + $this->assertEquals('IJKL', $item->getProductCode()); |
|
202 | 202 | } |
203 | 203 | } |
@@ -359,8 +359,7 @@ discard block |
||
359 | 359 | { |
360 | 360 | $this->object->addProduct( $item->getId(), 5, array(), array(), array(), array(), array(), 'unit_warehouse3' ); |
361 | 361 | throw new \Exception( 'Expected exception not thrown' ); |
362 | - } |
|
363 | - catch( \Aimeos\Controller\Frontend\Basket\Exception $e ) |
|
362 | + } catch( \Aimeos\Controller\Frontend\Basket\Exception $e ) |
|
364 | 363 | { |
365 | 364 | $item = $this->object->get()->getProduct( 0 ); |
366 | 365 | $this->assertEquals( 3, $item->getQuantity() ); |
@@ -385,8 +384,7 @@ discard block |
||
385 | 384 | { |
386 | 385 | $this->object->addProduct( $item->getId(), 5, array(), array(), array(), array(), array(), 'unit_warehouse2' ); |
387 | 386 | throw new \Exception( 'Expected exception not thrown' ); |
388 | - } |
|
389 | - catch( \Aimeos\Controller\Frontend\Basket\Exception $e ) |
|
387 | + } catch( \Aimeos\Controller\Frontend\Basket\Exception $e ) |
|
390 | 388 | { |
391 | 389 | $this->assertEquals( array(), $this->object->get()->getProducts() ); |
392 | 390 | } |
@@ -619,8 +617,7 @@ discard block |
||
619 | 617 | { |
620 | 618 | $this->object->editProduct( 0, 5 ); |
621 | 619 | throw new \Exception( 'Expected exception not thrown' ); |
622 | - } |
|
623 | - catch( \Aimeos\Controller\Frontend\Basket\Exception $e ) |
|
620 | + } catch( \Aimeos\Controller\Frontend\Basket\Exception $e ) |
|
624 | 621 | { |
625 | 622 | $item = $this->object->get()->getProduct( 0 ); |
626 | 623 | $this->assertEquals( 3, $item->getQuantity() ); |
@@ -657,8 +654,7 @@ discard block |
||
657 | 654 | { |
658 | 655 | $this->object->editProduct( $pos, 5 ); |
659 | 656 | throw new \Exception( 'Expected exception not thrown' ); |
660 | - } |
|
661 | - catch( \Aimeos\Controller\Frontend\Basket\Exception $e ) |
|
657 | + } catch( \Aimeos\Controller\Frontend\Basket\Exception $e ) |
|
662 | 658 | { |
663 | 659 | $this->assertEquals( 3, $this->object->get()->getProduct( $pos )->getQuantity() ); |
664 | 660 | } |
@@ -15,63 +15,63 @@ discard block |
||
15 | 15 | |
16 | 16 | protected function setUp() |
17 | 17 | { |
18 | - $this->object = new \Aimeos\Controller\Frontend\Catalog\Standard( \TestHelperFrontend::getContext() ); |
|
18 | + $this->object = new \Aimeos\Controller\Frontend\Catalog\Standard(\TestHelperFrontend::getContext()); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | |
22 | 22 | protected function tearDown() |
23 | 23 | { |
24 | - unset( $this->object ); |
|
24 | + unset($this->object); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | |
28 | 28 | public function testCreateManager() |
29 | 29 | { |
30 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Manager\\Iface', $this->object->createManager( 'product' ) ); |
|
30 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Manager\\Iface', $this->object->createManager('product')); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | 34 | public function testCreateCatalogFilter() |
35 | 35 | { |
36 | - $filter = $this->object->createCatalogFilter( true ); |
|
36 | + $filter = $this->object->createCatalogFilter(true); |
|
37 | 37 | |
38 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
39 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Expression\\Compare\\Iface', $filter->getConditions() ); |
|
40 | - $this->assertEquals( 'catalog.status', $filter->getConditions()->getName() ); |
|
38 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
39 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Expression\\Compare\\Iface', $filter->getConditions()); |
|
40 | + $this->assertEquals('catalog.status', $filter->getConditions()->getName()); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
44 | 44 | public function testGetCatalogPath() |
45 | 45 | { |
46 | - $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
47 | - $item = $manager->getTree( null, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST ); |
|
46 | + $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
47 | + $item = $manager->getTree(null, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST); |
|
48 | 48 | |
49 | 49 | $list = array(); |
50 | - foreach( $this->object->getCatalogPath( $item->getChild( 0 )->getId(), array( 'text' ) ) as $item ) { |
|
50 | + foreach ($this->object->getCatalogPath($item->getChild(0)->getId(), array('text')) as $item) { |
|
51 | 51 | $list[$item->getCode()] = $item; |
52 | 52 | } |
53 | 53 | |
54 | - $this->assertEquals( 2, count( $list ) ); |
|
55 | - $this->assertArrayHasKey( 'root', $list ); |
|
56 | - $this->assertArrayHasKey( 'categories', $list ); |
|
54 | + $this->assertEquals(2, count($list)); |
|
55 | + $this->assertArrayHasKey('root', $list); |
|
56 | + $this->assertArrayHasKey('categories', $list); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
60 | 60 | public function testGetCatalogTree() |
61 | 61 | { |
62 | - $item = $this->object->getCatalogTree( null, array( 'text' ), \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ); |
|
62 | + $item = $this->object->getCatalogTree(null, array('text'), \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE); |
|
63 | 63 | |
64 | - $this->assertEquals( 'Root', $item->getName() ); |
|
65 | - $this->assertEquals( 0, count( $item->getChildren() ) ); |
|
64 | + $this->assertEquals('Root', $item->getName()); |
|
65 | + $this->assertEquals(0, count($item->getChildren())); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
69 | 69 | public function testAggregateIndex() |
70 | 70 | { |
71 | 71 | $filter = $this->object->createIndexFilter(); |
72 | - $list = $this->object->aggregateIndex( $filter, 'index.attribute.id' ); |
|
72 | + $list = $this->object->aggregateIndex($filter, 'index.attribute.id'); |
|
73 | 73 | |
74 | - $this->assertGreaterThan( 0, count( $list ) ); |
|
74 | + $this->assertGreaterThan(0, count($list)); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -79,279 +79,279 @@ discard block |
||
79 | 79 | { |
80 | 80 | $filter = $this->object->createIndexFilter(); |
81 | 81 | |
82 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
83 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
84 | - $this->assertEquals( 0, $filter->getSliceStart() ); |
|
85 | - $this->assertEquals( 100, $filter->getSliceSize() ); |
|
82 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
83 | + $this->assertEquals(array(), $filter->getSortations()); |
|
84 | + $this->assertEquals(0, $filter->getSliceStart()); |
|
85 | + $this->assertEquals(100, $filter->getSliceSize()); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | |
89 | 89 | public function testCreateIndexFilterCategory() |
90 | 90 | { |
91 | - $filter = $this->object->createIndexFilterCategory( 0 ); |
|
91 | + $filter = $this->object->createIndexFilterCategory(0); |
|
92 | 92 | |
93 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
93 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
94 | 94 | |
95 | 95 | $list = $filter->getConditions()->getExpressions(); |
96 | 96 | |
97 | 97 | |
98 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
99 | - throw new \Exception( 'Wrong expression' ); |
|
98 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
99 | + throw new \Exception('Wrong expression'); |
|
100 | 100 | } |
101 | - $this->assertEquals( 'index.catalog.id', $list[0]->getName() ); |
|
102 | - $this->assertEquals( 0, $list[0]->getValue() ); |
|
101 | + $this->assertEquals('index.catalog.id', $list[0]->getName()); |
|
102 | + $this->assertEquals(0, $list[0]->getValue()); |
|
103 | 103 | |
104 | 104 | |
105 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
106 | - $this->assertEquals( 0, $filter->getSliceStart() ); |
|
107 | - $this->assertEquals( 100, $filter->getSliceSize() ); |
|
105 | + $this->assertEquals(array(), $filter->getSortations()); |
|
106 | + $this->assertEquals(0, $filter->getSliceStart()); |
|
107 | + $this->assertEquals(100, $filter->getSliceSize()); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | |
111 | 111 | public function testCreateIndexFilterCategoryPosition() |
112 | 112 | { |
113 | - $filter = $this->object->createIndexFilterCategory( 0, 'relevance', '-', 1, 2, 'test' ); |
|
113 | + $filter = $this->object->createIndexFilterCategory(0, 'relevance', '-', 1, 2, 'test'); |
|
114 | 114 | |
115 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
115 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
116 | 116 | |
117 | 117 | $sort = $filter->getSortations(); |
118 | - if( ( $item = reset( $sort ) ) === false ) { |
|
119 | - throw new \Exception( 'Sortation not set' ); |
|
118 | + if (($item = reset($sort)) === false) { |
|
119 | + throw new \Exception('Sortation not set'); |
|
120 | 120 | } |
121 | 121 | |
122 | - $this->assertEquals( 'sort:index.catalog.position("test",0)', $item->getName() ); |
|
123 | - $this->assertEquals( '-', $item->getOperator() ); |
|
122 | + $this->assertEquals('sort:index.catalog.position("test",0)', $item->getName()); |
|
123 | + $this->assertEquals('-', $item->getOperator()); |
|
124 | 124 | |
125 | - $this->assertEquals( 1, $filter->getSliceStart() ); |
|
126 | - $this->assertEquals( 2, $filter->getSliceSize() ); |
|
125 | + $this->assertEquals(1, $filter->getSliceStart()); |
|
126 | + $this->assertEquals(2, $filter->getSliceSize()); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
130 | 130 | public function testCreateIndexFilterCategoryCode() |
131 | 131 | { |
132 | - $filter = $this->object->createIndexFilterCategory( 0, 'code' ); |
|
132 | + $filter = $this->object->createIndexFilterCategory(0, 'code'); |
|
133 | 133 | |
134 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
134 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
135 | 135 | |
136 | 136 | $sort = $filter->getSortations(); |
137 | - if( ( $item = reset( $sort ) ) === false ) { |
|
138 | - throw new \Exception( 'Sortation not set' ); |
|
137 | + if (($item = reset($sort)) === false) { |
|
138 | + throw new \Exception('Sortation not set'); |
|
139 | 139 | } |
140 | 140 | |
141 | - $this->assertStringStartsWith( 'product.code', $item->getName() ); |
|
141 | + $this->assertStringStartsWith('product.code', $item->getName()); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | |
145 | 145 | public function testCreateIndexFilterCategoryName() |
146 | 146 | { |
147 | - $filter = $this->object->createIndexFilterCategory( 0, 'name' ); |
|
147 | + $filter = $this->object->createIndexFilterCategory(0, 'name'); |
|
148 | 148 | |
149 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
149 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
150 | 150 | |
151 | 151 | $sort = $filter->getSortations(); |
152 | - if( ( $item = reset( $sort ) ) === false ) { |
|
153 | - throw new \Exception( 'Sortation not set' ); |
|
152 | + if (($item = reset($sort)) === false) { |
|
153 | + throw new \Exception('Sortation not set'); |
|
154 | 154 | } |
155 | 155 | |
156 | - $this->assertEquals( 'sort:index.text.value("default","de","name")', $item->getName() ); |
|
156 | + $this->assertEquals('sort:index.text.value("default","de","name")', $item->getName()); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | |
160 | 160 | public function testCreateIndexFilterCategoryPrice() |
161 | 161 | { |
162 | - $filter = $this->object->createIndexFilterCategory( 0, 'price' ); |
|
162 | + $filter = $this->object->createIndexFilterCategory(0, 'price'); |
|
163 | 163 | |
164 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
164 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
165 | 165 | |
166 | 166 | $sort = $filter->getSortations(); |
167 | - if( ( $item = reset( $sort ) ) === false ) { |
|
168 | - throw new \Exception( 'Sortation not set' ); |
|
167 | + if (($item = reset($sort)) === false) { |
|
168 | + throw new \Exception('Sortation not set'); |
|
169 | 169 | } |
170 | 170 | |
171 | - $this->assertStringStartsWith( 'sort:index.price.value("default","EUR","default")', $item->getName() ); |
|
171 | + $this->assertStringStartsWith('sort:index.price.value("default","EUR","default")', $item->getName()); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
175 | 175 | public function testCreateIndexFilterCategoryInvalidSortation() |
176 | 176 | { |
177 | - $filter = $this->object->createIndexFilterCategory( 0, 'failure' ); |
|
177 | + $filter = $this->object->createIndexFilterCategory(0, 'failure'); |
|
178 | 178 | |
179 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
180 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
179 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
180 | + $this->assertEquals(array(), $filter->getSortations()); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | |
184 | 184 | public function testAddIndexFilterCategory() |
185 | 185 | { |
186 | 186 | $filter = $this->object->createIndexFilter(); |
187 | - $filter = $this->object->addIndexFilterCategory( $filter, 0 ); |
|
187 | + $filter = $this->object->addIndexFilterCategory($filter, 0); |
|
188 | 188 | |
189 | 189 | $list = $filter->getConditions()->getExpressions(); |
190 | 190 | |
191 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
192 | - throw new \Exception( 'Wrong expression' ); |
|
191 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
192 | + throw new \Exception('Wrong expression'); |
|
193 | 193 | } |
194 | 194 | |
195 | - $this->assertEquals( 'index.catalog.id', $list[0]->getName() ); |
|
196 | - $this->assertEquals( 0, $list[0]->getValue() ); |
|
197 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
195 | + $this->assertEquals('index.catalog.id', $list[0]->getName()); |
|
196 | + $this->assertEquals(0, $list[0]->getValue()); |
|
197 | + $this->assertEquals(array(), $filter->getSortations()); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | |
201 | 201 | public function testCreateIndexFilterText() |
202 | 202 | { |
203 | - $filter = $this->object->createIndexFilterText( 'Espresso' ); |
|
203 | + $filter = $this->object->createIndexFilterText('Espresso'); |
|
204 | 204 | |
205 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
205 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
206 | 206 | |
207 | 207 | $list = $filter->getConditions()->getExpressions(); |
208 | 208 | |
209 | 209 | |
210 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
211 | - throw new \Exception( 'Wrong expression' ); |
|
210 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
211 | + throw new \Exception('Wrong expression'); |
|
212 | 212 | } |
213 | - $this->assertEquals( 'index.text.relevance("default","de","Espresso")', $list[0]->getName() ); |
|
214 | - $this->assertEquals( 0, $list[0]->getValue() ); |
|
213 | + $this->assertEquals('index.text.relevance("default","de","Espresso")', $list[0]->getName()); |
|
214 | + $this->assertEquals(0, $list[0]->getValue()); |
|
215 | 215 | |
216 | 216 | |
217 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
218 | - $this->assertEquals( 0, $filter->getSliceStart() ); |
|
219 | - $this->assertEquals( 100, $filter->getSliceSize() ); |
|
217 | + $this->assertEquals(array(), $filter->getSortations()); |
|
218 | + $this->assertEquals(0, $filter->getSliceStart()); |
|
219 | + $this->assertEquals(100, $filter->getSliceSize()); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | |
223 | 223 | public function testCreateIndexFilterTextRelevance() |
224 | 224 | { |
225 | - $filter = $this->object->createIndexFilterText( 'Espresso', 'relevance', '-', 1, 2, 'test' ); |
|
225 | + $filter = $this->object->createIndexFilterText('Espresso', 'relevance', '-', 1, 2, 'test'); |
|
226 | 226 | |
227 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
228 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
229 | - $this->assertEquals( 1, $filter->getSliceStart() ); |
|
230 | - $this->assertEquals( 2, $filter->getSliceSize() ); |
|
227 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
228 | + $this->assertEquals(array(), $filter->getSortations()); |
|
229 | + $this->assertEquals(1, $filter->getSliceStart()); |
|
230 | + $this->assertEquals(2, $filter->getSliceSize()); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | |
234 | 234 | public function testCreateIndexFilterTextCode() |
235 | 235 | { |
236 | - $filter = $this->object->createIndexFilterText( 'Espresso', 'code' ); |
|
236 | + $filter = $this->object->createIndexFilterText('Espresso', 'code'); |
|
237 | 237 | |
238 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
238 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
239 | 239 | |
240 | 240 | $sort = $filter->getSortations(); |
241 | - if( ( $item = reset( $sort ) ) === false ) { |
|
242 | - throw new \Exception( 'Sortation not set' ); |
|
241 | + if (($item = reset($sort)) === false) { |
|
242 | + throw new \Exception('Sortation not set'); |
|
243 | 243 | } |
244 | 244 | |
245 | - $this->assertEquals( 'product.code', $item->getName() ); |
|
245 | + $this->assertEquals('product.code', $item->getName()); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | |
249 | 249 | public function testCreateIndexFilterTextName() |
250 | 250 | { |
251 | - $filter = $this->object->createIndexFilterText( 'Espresso', 'name' ); |
|
251 | + $filter = $this->object->createIndexFilterText('Espresso', 'name'); |
|
252 | 252 | |
253 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
253 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
254 | 254 | |
255 | 255 | $sort = $filter->getSortations(); |
256 | - if( ( $item = reset( $sort ) ) === false ) { |
|
257 | - throw new \Exception( 'Sortation not set' ); |
|
256 | + if (($item = reset($sort)) === false) { |
|
257 | + throw new \Exception('Sortation not set'); |
|
258 | 258 | } |
259 | 259 | |
260 | - $this->assertEquals( 'sort:index.text.value("default","de","name")', $item->getName() ); |
|
260 | + $this->assertEquals('sort:index.text.value("default","de","name")', $item->getName()); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | |
264 | 264 | public function testCreateIndexFilterTextPrice() |
265 | 265 | { |
266 | - $filter = $this->object->createIndexFilterCategory( 'Espresso', 'price' ); |
|
266 | + $filter = $this->object->createIndexFilterCategory('Espresso', 'price'); |
|
267 | 267 | |
268 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
268 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
269 | 269 | |
270 | 270 | $sort = $filter->getSortations(); |
271 | - if( ( $item = reset( $sort ) ) === false ) { |
|
272 | - throw new \Exception( 'Sortation not set' ); |
|
271 | + if (($item = reset($sort)) === false) { |
|
272 | + throw new \Exception('Sortation not set'); |
|
273 | 273 | } |
274 | 274 | |
275 | - $this->assertStringStartsWith( 'sort:index.price.value("default","EUR","default")', $item->getName() ); |
|
275 | + $this->assertStringStartsWith('sort:index.price.value("default","EUR","default")', $item->getName()); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | |
279 | 279 | public function testCreateIndexFilterTextInvalidSortation() |
280 | 280 | { |
281 | - $filter = $this->object->createIndexFilterText( '', 'failure' ); |
|
281 | + $filter = $this->object->createIndexFilterText('', 'failure'); |
|
282 | 282 | |
283 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
284 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
283 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
284 | + $this->assertEquals(array(), $filter->getSortations()); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | |
288 | 288 | public function testAddIndexFilterText() |
289 | 289 | { |
290 | - $filter = $this->object->createIndexFilterText( 'Espresso' ); |
|
291 | - $filter = $this->object->addIndexFilterText( $filter, 'Espresso' ); |
|
290 | + $filter = $this->object->createIndexFilterText('Espresso'); |
|
291 | + $filter = $this->object->addIndexFilterText($filter, 'Espresso'); |
|
292 | 292 | |
293 | 293 | $list = $filter->getConditions()->getExpressions(); |
294 | 294 | |
295 | - if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) { |
|
296 | - throw new \Exception( 'Wrong expression' ); |
|
295 | + if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) { |
|
296 | + throw new \Exception('Wrong expression'); |
|
297 | 297 | } |
298 | 298 | |
299 | - $this->assertEquals( 'index.text.relevance("default","de","Espresso")', $list[0]->getName() ); |
|
300 | - $this->assertEquals( 0, $list[0]->getValue() ); |
|
301 | - $this->assertEquals( array(), $filter->getSortations() ); |
|
299 | + $this->assertEquals('index.text.relevance("default","de","Espresso")', $list[0]->getName()); |
|
300 | + $this->assertEquals(0, $list[0]->getValue()); |
|
301 | + $this->assertEquals(array(), $filter->getSortations()); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | |
305 | 305 | public function testGetIndexItemsCategory() |
306 | 306 | { |
307 | - $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
307 | + $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
308 | 308 | $search = $catalogManager->createSearch(); |
309 | 309 | |
310 | - $search->setConditions( $search->compare( '==', 'catalog.code', 'new' ) ); |
|
311 | - $search->setSlice( 0, 1 ); |
|
312 | - $items = $catalogManager->searchItems( $search ); |
|
310 | + $search->setConditions($search->compare('==', 'catalog.code', 'new')); |
|
311 | + $search->setSlice(0, 1); |
|
312 | + $items = $catalogManager->searchItems($search); |
|
313 | 313 | |
314 | - if( ( $item = reset( $items ) ) === false ) { |
|
315 | - throw new \Exception( 'Catalog item not found' ); |
|
314 | + if (($item = reset($items)) === false) { |
|
315 | + throw new \Exception('Catalog item not found'); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | $total = 0; |
319 | - $filter = $this->object->createIndexFilterCategory( $item->getId(), 'position', '+', 1, 1 ); |
|
320 | - $results = $this->object->getIndexItems( $filter, array(), $total ); |
|
319 | + $filter = $this->object->createIndexFilterCategory($item->getId(), 'position', '+', 1, 1); |
|
320 | + $results = $this->object->getIndexItems($filter, array(), $total); |
|
321 | 321 | |
322 | - $this->assertEquals( 3, $total ); |
|
323 | - $this->assertEquals( 1, count( $results ) ); |
|
322 | + $this->assertEquals(3, $total); |
|
323 | + $this->assertEquals(1, count($results)); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | |
327 | 327 | public function testGetIndexItemsText() |
328 | 328 | { |
329 | 329 | $total = 0; |
330 | - $filter = $this->object->createIndexFilterText( 'Expresso', 'relevance', '+', 0, 1, 'unittype13' ); |
|
331 | - $results = $this->object->getIndexItems( $filter, array(), $total ); |
|
330 | + $filter = $this->object->createIndexFilterText('Expresso', 'relevance', '+', 0, 1, 'unittype13'); |
|
331 | + $results = $this->object->getIndexItems($filter, array(), $total); |
|
332 | 332 | |
333 | - $this->assertEquals( 1, $total ); |
|
334 | - $this->assertEquals( 1, count( $results ) ); |
|
333 | + $this->assertEquals(1, $total); |
|
334 | + $this->assertEquals(1, count($results)); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | |
338 | 338 | public function testCreateTextFilter() |
339 | 339 | { |
340 | - $filter = $this->object->createTextFilter( 'Expresso', 'name', '+', 0, 1 ); |
|
340 | + $filter = $this->object->createTextFilter('Expresso', 'name', '+', 0, 1); |
|
341 | 341 | |
342 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter ); |
|
343 | - $this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Expression\\Combine\\Iface', $filter->getConditions() ); |
|
344 | - $this->assertEquals( 3, count( $filter->getConditions()->getExpressions() ) ); |
|
342 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter); |
|
343 | + $this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Expression\\Combine\\Iface', $filter->getConditions()); |
|
344 | + $this->assertEquals(3, count($filter->getConditions()->getExpressions())); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | |
348 | 348 | public function testGetTextListName() |
349 | 349 | { |
350 | - $filter = $this->object->createTextFilter( 'Cafe Noire', 'relevance', '-', 0, 25, 'unittype19', 'name' ); |
|
351 | - $results = $this->object->getTextList( $filter ); |
|
350 | + $filter = $this->object->createTextFilter('Cafe Noire', 'relevance', '-', 0, 25, 'unittype19', 'name'); |
|
351 | + $results = $this->object->getTextList($filter); |
|
352 | 352 | |
353 | - $this->assertEquals( 1, count( $results ) ); |
|
354 | - $this->assertContains( 'Cafe Noire Cappuccino', $results ); |
|
353 | + $this->assertEquals(1, count($results)); |
|
354 | + $this->assertContains('Cafe Noire Cappuccino', $results); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | } |
@@ -41,29 +41,29 @@ discard block |
||
41 | 41 | * @param string $warehouse Unique code of the warehouse to deliver the products from |
42 | 42 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
43 | 43 | */ |
44 | - public function addProduct( $prodid, $quantity = 1, array $options = array(), array $variantIds = array(), |
|
45 | - array $configIds = array(), array $hiddenIds = array(), array $customValues = array(), $warehouse = 'default' ) |
|
44 | + public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantIds = array(), |
|
45 | + array $configIds = array(), array $hiddenIds = array(), array $customValues = array(), $warehouse = 'default') |
|
46 | 46 | { |
47 | 47 | $stocklevel = null; |
48 | 48 | |
49 | - if( !isset( $options['stock'] ) || $options['stock'] != false ) { |
|
50 | - $stocklevel = $this->getStockLevel( $prodid, $warehouse ); |
|
49 | + if (!isset($options['stock']) || $options['stock'] != false) { |
|
50 | + $stocklevel = $this->getStockLevel($prodid, $warehouse); |
|
51 | 51 | } |
52 | 52 | |
53 | - $qty = ( $stocklevel !== null ? min( $stocklevel, $quantity ) : $quantity ); |
|
53 | + $qty = ($stocklevel !== null ? min($stocklevel, $quantity) : $quantity); |
|
54 | 54 | |
55 | - if( $qty > 0 ) |
|
55 | + if ($qty > 0) |
|
56 | 56 | { |
57 | 57 | $this->getController()->addProduct( |
58 | 58 | $prodid, $qty, $options, $variantIds, $configIds, $hiddenIds, $customValues, $warehouse |
59 | 59 | ); |
60 | 60 | } |
61 | 61 | |
62 | - if( $qty < $quantity ) |
|
62 | + if ($qty < $quantity) |
|
63 | 63 | { |
64 | - $product = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' )->getItem( $prodid ); |
|
65 | - $msg = sprintf( 'There are not enough products "%1$s" in stock', $product->getName() ); |
|
66 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
64 | + $product = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product')->getItem($prodid); |
|
65 | + $msg = sprintf('There are not enough products "%1$s" in stock', $product->getName()); |
|
66 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
@@ -77,23 +77,23 @@ discard block |
||
77 | 77 | * The 'stock'=>false option allows adding products without being in stock. |
78 | 78 | * @param string[] $configCodes Codes of the product config attributes that should be REMOVED |
79 | 79 | */ |
80 | - public function editProduct( $position, $quantity, array $options = array(), array $configCodes = array() ) |
|
80 | + public function editProduct($position, $quantity, array $options = array(), array $configCodes = array()) |
|
81 | 81 | { |
82 | 82 | $stocklevel = null; |
83 | - $product = $this->getController()->get()->getProduct( $position ); |
|
83 | + $product = $this->getController()->get()->getProduct($position); |
|
84 | 84 | |
85 | - if( !isset( $options['stock'] ) || $options['stock'] != false ) { |
|
86 | - $stocklevel = $this->getStockLevel( $product->getProductId(), $product->getWarehouseCode() ); |
|
85 | + if (!isset($options['stock']) || $options['stock'] != false) { |
|
86 | + $stocklevel = $this->getStockLevel($product->getProductId(), $product->getWarehouseCode()); |
|
87 | 87 | } |
88 | 88 | |
89 | - $qty = ( $stocklevel !== null ? min( $stocklevel, $quantity ) : $quantity ); |
|
89 | + $qty = ($stocklevel !== null ? min($stocklevel, $quantity) : $quantity); |
|
90 | 90 | |
91 | - $this->getController()->editProduct( $position, $qty, $options, $configCodes ); |
|
91 | + $this->getController()->editProduct($position, $qty, $options, $configCodes); |
|
92 | 92 | |
93 | - if( $qty < $quantity ) |
|
93 | + if ($qty < $quantity) |
|
94 | 94 | { |
95 | - $msg = sprintf( 'There are not enough products "%1$s" in stock', $product->getName() ); |
|
96 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
95 | + $msg = sprintf('There are not enough products "%1$s" in stock', $product->getName()); |
|
96 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
@@ -105,35 +105,35 @@ discard block |
||
105 | 105 | * @param string $warehouse Unique code of the warehouse |
106 | 106 | * @return integer|null Number of available items in stock (null for unlimited stock) |
107 | 107 | */ |
108 | - protected function getStockLevel( $prodid, $warehouse ) |
|
108 | + protected function getStockLevel($prodid, $warehouse) |
|
109 | 109 | { |
110 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/stock' ); |
|
110 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/stock'); |
|
111 | 111 | |
112 | - $search = $manager->createSearch( true ); |
|
112 | + $search = $manager->createSearch(true); |
|
113 | 113 | $expr = array( |
114 | - $search->compare( '==', 'product.stock.parentid', $prodid ), |
|
114 | + $search->compare('==', 'product.stock.parentid', $prodid), |
|
115 | 115 | $search->getConditions(), |
116 | - $search->compare( '==', 'product.stock.warehouse.code', $warehouse ), |
|
116 | + $search->compare('==', 'product.stock.warehouse.code', $warehouse), |
|
117 | 117 | ); |
118 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
118 | + $search->setConditions($search->combine('&&', $expr)); |
|
119 | 119 | |
120 | - $result = $manager->searchItems( $search ); |
|
120 | + $result = $manager->searchItems($search); |
|
121 | 121 | |
122 | - if( empty( $result ) ) |
|
122 | + if (empty($result)) |
|
123 | 123 | { |
124 | - $msg = sprintf( 'No stock for product ID "%1$s" and warehouse "%2$s" available', $prodid, $warehouse ); |
|
125 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
124 | + $msg = sprintf('No stock for product ID "%1$s" and warehouse "%2$s" available', $prodid, $warehouse); |
|
125 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | $stocklevel = null; |
129 | 129 | |
130 | - foreach( $result as $item ) |
|
130 | + foreach ($result as $item) |
|
131 | 131 | { |
132 | - if( ( $stock = $item->getStockLevel() ) === null ) { |
|
132 | + if (($stock = $item->getStockLevel()) === null) { |
|
133 | 133 | return null; |
134 | 134 | } |
135 | 135 | |
136 | - $stocklevel = max( (int) $stocklevel, $item->getStockLevel() ); |
|
136 | + $stocklevel = max((int) $stocklevel, $item->getStockLevel()); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | return $stocklevel; |