@@ -17,104 +17,104 @@ |
||
17 | 17 | |
18 | 18 | protected function setUp() |
19 | 19 | { |
20 | - \Aimeos\MShop\Factory::setCache( true ); |
|
20 | + \Aimeos\MShop\Factory::setCache(true); |
|
21 | 21 | |
22 | 22 | $this->context = \TestHelperFrontend::getContext(); |
23 | - $this->object = new \Aimeos\Controller\Frontend\Subscription\Standard( $this->context ); |
|
23 | + $this->object = new \Aimeos\Controller\Frontend\Subscription\Standard($this->context); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | |
27 | 27 | protected function tearDown() |
28 | 28 | { |
29 | - unset( $this->object, $this->context ); |
|
29 | + unset($this->object, $this->context); |
|
30 | 30 | |
31 | - \Aimeos\MShop\Factory::setCache( false ); |
|
31 | + \Aimeos\MShop\Factory::setCache(false); |
|
32 | 32 | \Aimeos\MShop\Factory::clear(); |
33 | 33 | } |
34 | 34 | |
35 | 35 | |
36 | 36 | public function testCancel() |
37 | 37 | { |
38 | - $this->context->setUserId( $this->getCustomerId() ); |
|
39 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'subscription' )->createItem(); |
|
38 | + $this->context->setUserId($this->getCustomerId()); |
|
39 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'subscription')->createItem(); |
|
40 | 40 | |
41 | - $cntl = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Subscription\Standard' ) |
|
42 | - ->setConstructorArgs( [$this->context] ) |
|
43 | - ->setMethods( ['saveItem'] ) |
|
41 | + $cntl = $this->getMockBuilder('\Aimeos\Controller\Frontend\Subscription\Standard') |
|
42 | + ->setConstructorArgs([$this->context]) |
|
43 | + ->setMethods(['saveItem']) |
|
44 | 44 | ->getMock(); |
45 | 45 | |
46 | - $cntl->expects( $this->once() )->method( 'saveItem' ) |
|
47 | - ->will( $this->returnValue( $item ) ); |
|
46 | + $cntl->expects($this->once())->method('saveItem') |
|
47 | + ->will($this->returnValue($item)); |
|
48 | 48 | |
49 | - $this->assertInstanceOf( '\Aimeos\MShop\Subscription\Item\Iface', $cntl->cancel( $this->getSubscriptionId() ) ); |
|
49 | + $this->assertInstanceOf('\Aimeos\MShop\Subscription\Item\Iface', $cntl->cancel($this->getSubscriptionId())); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
53 | 53 | public function testCreateFilter() |
54 | 54 | { |
55 | - $this->assertInstanceOf( '\Aimeos\MW\Criteria\Iface', $this->object->createFilter() ); |
|
55 | + $this->assertInstanceOf('\Aimeos\MW\Criteria\Iface', $this->object->createFilter()); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
59 | 59 | public function testGetIntervals() |
60 | 60 | { |
61 | - $this->assertGreaterThan( 0, count( $this->object->getIntervals() ) ); |
|
61 | + $this->assertGreaterThan(0, count($this->object->getIntervals())); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | |
65 | 65 | public function testGetItem() |
66 | 66 | { |
67 | 67 | $id = $this->getSubscriptionId(); |
68 | - $this->context->setUserId( $this->getCustomerId() ); |
|
68 | + $this->context->setUserId($this->getCustomerId()); |
|
69 | 69 | |
70 | - $this->assertInstanceOf( '\Aimeos\MShop\Subscription\Item\Iface', $this->object->getItem( $id ) ); |
|
70 | + $this->assertInstanceOf('\Aimeos\MShop\Subscription\Item\Iface', $this->object->getItem($id)); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | |
74 | 74 | public function testGetItemException() |
75 | 75 | { |
76 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Subscription\Exception' ); |
|
76 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Subscription\Exception'); |
|
77 | 77 | $this->object->getItem( -1 ); |
78 | 78 | } |
79 | 79 | |
80 | 80 | |
81 | 81 | public function testSaveItem() |
82 | 82 | { |
83 | - $manager = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' ) |
|
84 | - ->setConstructorArgs( [$this->context] ) |
|
85 | - ->setMethods( ['saveItem'] ) |
|
83 | + $manager = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard') |
|
84 | + ->setConstructorArgs([$this->context]) |
|
85 | + ->setMethods(['saveItem']) |
|
86 | 86 | ->getMock(); |
87 | 87 | |
88 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'subscription', $manager ); |
|
88 | + \Aimeos\MShop\Factory::injectManager($this->context, 'subscription', $manager); |
|
89 | 89 | |
90 | - $manager->expects( $this->once() )->method( 'saveItem' ) |
|
91 | - ->will( $this->returnValue( $manager->createItem() ) ); |
|
90 | + $manager->expects($this->once())->method('saveItem') |
|
91 | + ->will($this->returnValue($manager->createItem())); |
|
92 | 92 | |
93 | - $this->assertInstanceOf( '\Aimeos\MShop\Subscription\Item\Iface', $this->object->saveItem( $manager->createItem() ) ); |
|
93 | + $this->assertInstanceOf('\Aimeos\MShop\Subscription\Item\Iface', $this->object->saveItem($manager->createItem())); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | |
97 | 97 | public function testSearchItems() |
98 | 98 | { |
99 | - $this->assertGreaterThan( 1, $this->object->searchItems( $this->object->createFilter() ) ); |
|
99 | + $this->assertGreaterThan(1, $this->object->searchItems($this->object->createFilter())); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | protected function getCustomerId() |
103 | 103 | { |
104 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' ); |
|
105 | - return $manager->findItem( 'UTC001' )->getId(); |
|
104 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer'); |
|
105 | + return $manager->findItem('UTC001')->getId(); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
109 | 109 | protected function getSubscriptionId() |
110 | 110 | { |
111 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'subscription' ); |
|
112 | - $search = $manager->createSearch()->setSlice( 0, 1 ); |
|
113 | - $search->setConditions( $search->compare( '==', 'order.base.customerid', $this->getCustomerId() ) ); |
|
114 | - $result = $manager->searchItems( $search ); |
|
111 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'subscription'); |
|
112 | + $search = $manager->createSearch()->setSlice(0, 1); |
|
113 | + $search->setConditions($search->compare('==', 'order.base.customerid', $this->getCustomerId())); |
|
114 | + $result = $manager->searchItems($search); |
|
115 | 115 | |
116 | - if( ( $item = reset( $result ) ) === false ) { |
|
117 | - throw new \RuntimeException( 'No subscription item found' ); |
|
116 | + if (($item = reset($result)) === false) { |
|
117 | + throw new \RuntimeException('No subscription item found'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | return $item->getId(); |
@@ -15,31 +15,31 @@ |
||
15 | 15 | { |
16 | 16 | $target = '\\Aimeos\\Controller\\Frontend\\Subscription\\Iface'; |
17 | 17 | |
18 | - $controller = \Aimeos\Controller\Frontend\Subscription\Factory::createController( \TestHelperFrontend::getContext() ); |
|
19 | - $this->assertInstanceOf( $target, $controller ); |
|
18 | + $controller = \Aimeos\Controller\Frontend\Subscription\Factory::createController(\TestHelperFrontend::getContext()); |
|
19 | + $this->assertInstanceOf($target, $controller); |
|
20 | 20 | |
21 | - $controller = \Aimeos\Controller\Frontend\Subscription\Factory::createController( \TestHelperFrontend::getContext(), 'Standard' ); |
|
22 | - $this->assertInstanceOf( $target, $controller ); |
|
21 | + $controller = \Aimeos\Controller\Frontend\Subscription\Factory::createController(\TestHelperFrontend::getContext(), 'Standard'); |
|
22 | + $this->assertInstanceOf($target, $controller); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | |
26 | 26 | public function testCreateControllerInvalidImplementation() |
27 | 27 | { |
28 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' ); |
|
29 | - \Aimeos\Controller\Frontend\Subscription\Factory::createController( \TestHelperFrontend::getContext(), 'Invalid' ); |
|
28 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception'); |
|
29 | + \Aimeos\Controller\Frontend\Subscription\Factory::createController(\TestHelperFrontend::getContext(), 'Invalid'); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | |
33 | 33 | public function testCreateControllerInvalidName() |
34 | 34 | { |
35 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' ); |
|
36 | - \Aimeos\Controller\Frontend\Subscription\Factory::createController( \TestHelperFrontend::getContext(), '%^' ); |
|
35 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception'); |
|
36 | + \Aimeos\Controller\Frontend\Subscription\Factory::createController(\TestHelperFrontend::getContext(), '%^'); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
40 | 40 | public function testCreateControllerNotExisting() |
41 | 41 | { |
42 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' ); |
|
43 | - \Aimeos\Controller\Frontend\Subscription\Factory::createController( \TestHelperFrontend::getContext(), 'notexist' ); |
|
42 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception'); |
|
43 | + \Aimeos\Controller\Frontend\Subscription\Factory::createController(\TestHelperFrontend::getContext(), 'notexist'); |
|
44 | 44 | } |
45 | 45 | } |
@@ -27,14 +27,14 @@ discard block |
||
27 | 27 | * @param string $id Unique subscription ID |
28 | 28 | * @return \Aimeos\MShop\Subscription\Item\Iface Canceled subscription item |
29 | 29 | */ |
30 | - public function cancel( $id ) |
|
30 | + public function cancel($id) |
|
31 | 31 | { |
32 | - $item = $this->getItem( $id ); |
|
32 | + $item = $this->getItem($id); |
|
33 | 33 | |
34 | - $interval = \DateInterval::createFromDateString( $item->getInterval() ); |
|
35 | - $item->setDateEnd( date_create( $item->getDateNext() )->add( $interval )->format( 'Y-m-d' ) ); |
|
34 | + $interval = \DateInterval::createFromDateString($item->getInterval()); |
|
35 | + $item->setDateEnd(date_create($item->getDateNext())->add($interval)->format('Y-m-d')); |
|
36 | 36 | |
37 | - return $this->saveItem( $item ); |
|
37 | + return $this->saveItem($item); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function createFilter() |
47 | 47 | { |
48 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'subscription' )->createSearch(); |
|
48 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'subscription')->createSearch(); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -55,25 +55,25 @@ discard block |
||
55 | 55 | * @param string $id Unique subscription ID |
56 | 56 | * @return \Aimeos\MShop\Subscription\Item\Iface Subscription object |
57 | 57 | */ |
58 | - public function getItem( $id ) |
|
58 | + public function getItem($id) |
|
59 | 59 | { |
60 | 60 | $context = $this->getContext(); |
61 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'subscription' ); |
|
61 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'subscription'); |
|
62 | 62 | |
63 | 63 | $filter = $manager->createSearch(); |
64 | 64 | $expr = [ |
65 | - $filter->compare( '==', 'subscription.id', $id ), |
|
66 | - $filter->compare( '==', 'order.base.customerid', $context->getUserId() ), |
|
65 | + $filter->compare('==', 'subscription.id', $id), |
|
66 | + $filter->compare('==', 'order.base.customerid', $context->getUserId()), |
|
67 | 67 | $filter->getConditions(), |
68 | 68 | ]; |
69 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
69 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
70 | 70 | |
71 | - $items = $this->searchItems( $filter ); |
|
71 | + $items = $this->searchItems($filter); |
|
72 | 72 | |
73 | - if( ( $item = reset( $items ) ) === false ) |
|
73 | + if (($item = reset($items)) === false) |
|
74 | 74 | { |
75 | 75 | $msg = 'Invalid subscription ID "%1$s" for customer ID "%2$s"'; |
76 | - throw new \Aimeos\Controller\Frontend\Subscription\Exception( sprintf( $msg, $id, $context->getUserId() ) ); |
|
76 | + throw new \Aimeos\Controller\Frontend\Subscription\Exception(sprintf($msg, $id, $context->getUserId())); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | return $item; |
@@ -88,18 +88,18 @@ discard block |
||
88 | 88 | public function getIntervals() |
89 | 89 | { |
90 | 90 | $intervals = []; |
91 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
91 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
92 | 92 | |
93 | - $search = $manager->createSearch( true ); |
|
93 | + $search = $manager->createSearch(true); |
|
94 | 94 | $expr = array( |
95 | 95 | $search->getConditions(), |
96 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
97 | - $search->compare( '==', 'attribute.type.code', 'interval' ), |
|
96 | + $search->compare('==', 'attribute.domain', 'product'), |
|
97 | + $search->compare('==', 'attribute.type.code', 'interval'), |
|
98 | 98 | ); |
99 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
100 | - $search->setSlice( 0, 0x7fffffff ); |
|
99 | + $search->setConditions($search->combine('&&', $expr)); |
|
100 | + $search->setSlice(0, 0x7fffffff); |
|
101 | 101 | |
102 | - foreach( $manager->searchItems( $search, ['text'] ) as $attrItem ) { |
|
102 | + foreach ($manager->searchItems($search, ['text']) as $attrItem) { |
|
103 | 103 | $intervals[$attrItem->getCode()] = $attrItem; |
104 | 104 | } |
105 | 105 | |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | * @param \Aimeos\MShop\Subscription\Item\Iface $item Subscription object |
113 | 113 | * @return \Aimeos\MShop\Subscription\Item\Iface Saved subscription item |
114 | 114 | */ |
115 | - public function saveItem( \Aimeos\MShop\Subscription\Item\Iface $item ) |
|
115 | + public function saveItem(\Aimeos\MShop\Subscription\Item\Iface $item) |
|
116 | 116 | { |
117 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'subscription' )->saveItem( $item ); |
|
117 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'subscription')->saveItem($item); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | |
@@ -125,17 +125,17 @@ discard block |
||
125 | 125 | * @param integer &$total|null Variable that will contain the total number of available items |
126 | 126 | * @return \Aimeos\MShop\Subscription\Item\Iface[] Associative list of IDs as keys and subscription objects as values |
127 | 127 | */ |
128 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, &$total = null ) |
|
128 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, &$total = null) |
|
129 | 129 | { |
130 | 130 | $context = $this->getContext(); |
131 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'subscription' ); |
|
131 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'subscription'); |
|
132 | 132 | |
133 | 133 | $expr = [ |
134 | - $filter->compare( '==', 'order.base.customerid', $context->getUserId() ), |
|
134 | + $filter->compare('==', 'order.base.customerid', $context->getUserId()), |
|
135 | 135 | $filter->getConditions(), |
136 | 136 | ]; |
137 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
137 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
138 | 138 | |
139 | - return $manager->searchItems( $filter, [], $total ); |
|
139 | + return $manager->searchItems($filter, [], $total); |
|
140 | 140 | } |
141 | 141 | } |