Completed
Push — master ( 8d5e0f...0ed5fa )
by Aimeos
02:42
created
jobs/tests/Controller/Jobs/Subscription/Process/Begin/StanardTest.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -20,49 +20,49 @@  discard block
 block discarded – undo
20 20
 		$aimeos = \TestHelperJobs::getAimeos();
21 21
 		$this->context = \TestHelperJobs::getContext();
22 22
 
23
-		$this->object = new \Aimeos\Controller\Jobs\Subscription\Process\Begin\Standard( $this->context, $aimeos );
23
+		$this->object = new \Aimeos\Controller\Jobs\Subscription\Process\Begin\Standard($this->context, $aimeos);
24 24
 
25
-		\Aimeos\MShop\Factory::setCache( true );
25
+		\Aimeos\MShop\Factory::setCache(true);
26 26
 	}
27 27
 
28 28
 
29 29
 	protected function tearDown()
30 30
 	{
31
-		\Aimeos\MShop\Factory::setCache( false );
31
+		\Aimeos\MShop\Factory::setCache(false);
32 32
 		\Aimeos\MShop\Factory::clear();
33 33
 
34
-		unset( $this->object, $this->context );
34
+		unset($this->object, $this->context);
35 35
 	}
36 36
 
37 37
 
38 38
 	public function testGetName()
39 39
 	{
40
-		$this->assertEquals( 'Subscription process start', $this->object->getName() );
40
+		$this->assertEquals('Subscription process start', $this->object->getName());
41 41
 	}
42 42
 
43 43
 
44 44
 	public function testGetDescription()
45 45
 	{
46
-		$this->assertEquals( 'Process subscriptions initially', $this->object->getDescription() );
46
+		$this->assertEquals('Process subscriptions initially', $this->object->getDescription());
47 47
 	}
48 48
 
49 49
 
50 50
 	public function testRun()
51 51
 	{
52
-		$this->context->getConfig()->set( 'controller/common/subscription/process/processors', ['cgroup'] );
52
+		$this->context->getConfig()->set('controller/common/subscription/process/processors', ['cgroup']);
53 53
 		$item = $this->getSubscription();
54 54
 
55
-		$managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' )
56
-			->setConstructorArgs( [$this->context] )
57
-			->setMethods( ['searchItems', 'saveItem'] )
55
+		$managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard')
56
+			->setConstructorArgs([$this->context])
57
+			->setMethods(['searchItems', 'saveItem'])
58 58
 			->getMock();
59 59
 
60
-		\Aimeos\MShop\Factory::injectManager( $this->context, 'subscription', $managerStub );
60
+		\Aimeos\MShop\Factory::injectManager($this->context, 'subscription', $managerStub);
61 61
 
62
-		$managerStub->expects( $this->once() )->method( 'searchItems' )
63
-			->will( $this->returnValue( [$item] ) );
62
+		$managerStub->expects($this->once())->method('searchItems')
63
+			->will($this->returnValue([$item]));
64 64
 
65
-		$managerStub->expects( $this->once() )->method( 'saveItem' );
65
+		$managerStub->expects($this->once())->method('saveItem');
66 66
 
67 67
 		$this->object->run();
68 68
 	}
@@ -70,21 +70,21 @@  discard block
 block discarded – undo
70 70
 
71 71
 	public function testRunException()
72 72
 	{
73
-		$this->context->getConfig()->set( 'controller/common/subscription/process/processors', ['cgroup'] );
74
-		$this->context->getConfig()->set( 'controller/common/subscription/process/processor/cgroup/groupids', ['1'] );
73
+		$this->context->getConfig()->set('controller/common/subscription/process/processors', ['cgroup']);
74
+		$this->context->getConfig()->set('controller/common/subscription/process/processor/cgroup/groupids', ['1']);
75 75
 
76
-		$managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' )
77
-			->setConstructorArgs( [$this->context] )
78
-			->setMethods( ['searchItems', 'saveItem'] )
76
+		$managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard')
77
+			->setConstructorArgs([$this->context])
78
+			->setMethods(['searchItems', 'saveItem'])
79 79
 			->getMock();
80 80
 
81
-		\Aimeos\MShop\Factory::injectManager( $this->context, 'subscription', $managerStub );
81
+		\Aimeos\MShop\Factory::injectManager($this->context, 'subscription', $managerStub);
82 82
 
83
-		$managerStub->expects( $this->once() )->method( 'searchItems' )
84
-			->will( $this->returnValue( [$managerStub->createItem()] ) );
83
+		$managerStub->expects($this->once())->method('searchItems')
84
+			->will($this->returnValue([$managerStub->createItem()]));
85 85
 
86
-		$managerStub->expects( $this->once() )->method( 'saveItem' )
87
-			->will( $this->throwException( new \Exception() ) );
86
+		$managerStub->expects($this->once())->method('saveItem')
87
+			->will($this->throwException(new \Exception()));
88 88
 
89 89
 		$this->object->run();
90 90
 	}
@@ -92,17 +92,17 @@  discard block
 block discarded – undo
92 92
 
93 93
 	protected function getSubscription()
94 94
 	{
95
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'subscription' );
95
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'subscription');
96 96
 
97 97
 		$search = $manager->createSearch();
98
-		$search->setConditions( $search->compare( '==', 'subscription.dateend', '2010-01-01' ) );
98
+		$search->setConditions($search->compare('==', 'subscription.dateend', '2010-01-01'));
99 99
 
100
-		$items = $manager->searchItems( $search );
100
+		$items = $manager->searchItems($search);
101 101
 
102
-		if( ( $item = reset( $items ) ) !== false ) {
102
+		if (($item = reset($items)) !== false) {
103 103
 			return $item;
104 104
 		}
105 105
 
106
-		throw new \Exception( 'No subscription item found' );
106
+		throw new \Exception('No subscription item found');
107 107
 	}
108 108
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Subscription/Process/Begin/Standard.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function getName()
30 30
 	{
31
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Subscription process start' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Subscription process start');
32 32
 	}
33 33
 
34 34
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function getDescription()
41 41
 	{
42
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Process subscriptions initially' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Process subscriptions initially');
43 43
 	}
44 44
 
45 45
 
@@ -65,19 +65,19 @@  discard block
 block discarded – undo
65 65
 		 * @since 2018.04
66 66
 		 * @category Developer
67 67
 		 */
68
-		$names = (array) $config->get( 'controller/common/subscription/process/processors', [] );
68
+		$names = (array) $config->get('controller/common/subscription/process/processors', []);
69 69
 
70
-		$processors = $this->getProcessors( $names );
71
-		$orderManager = \Aimeos\MShop\Factory::createManager( $context, 'order' );
72
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'subscription' );
70
+		$processors = $this->getProcessors($names);
71
+		$orderManager = \Aimeos\MShop\Factory::createManager($context, 'order');
72
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'subscription');
73 73
 
74
-		$search = $manager->createSearch( true );
74
+		$search = $manager->createSearch(true);
75 75
 		$expr = [
76
-			$search->compare( '==', 'subscription.datenext', null ),
76
+			$search->compare('==', 'subscription.datenext', null),
77 77
 			$search->getConditions(),
78 78
 		];
79
-		$search->setConditions( $search->combine( '&&', $expr ) );
80
-		$search->setSortations( [$search->sort( '+', 'subscription.id' )] );
79
+		$search->setConditions($search->combine('&&', $expr));
80
+		$search->setSortations([$search->sort('+', 'subscription.id')]);
81 81
 
82 82
 		$status = \Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED;
83 83
 		$start = 0;
@@ -86,51 +86,51 @@  discard block
 block discarded – undo
86 86
 		{
87 87
 			$ordBaseIds = $payStatus = [];
88 88
 
89
-			$search->setSlice( $start, 100 );
90
-			$items = $manager->searchItems( $search );
89
+			$search->setSlice($start, 100);
90
+			$items = $manager->searchItems($search);
91 91
 
92
-			foreach( $items as $item ) {
92
+			foreach ($items as $item) {
93 93
 				$ordBaseIds[] = $item->getOrderBaseId();
94 94
 			}
95 95
 
96
-			$orderSearch = $orderManager->createSearch()->setSlice( 0, $search->getSliceSize() );
97
-			$orderSearch->setConditions( $orderSearch->compare( '==', 'order.base.id', $ordBaseIds ) );
96
+			$orderSearch = $orderManager->createSearch()->setSlice(0, $search->getSliceSize());
97
+			$orderSearch->setConditions($orderSearch->compare('==', 'order.base.id', $ordBaseIds));
98 98
 
99
-			foreach( $orderManager->searchItems( $orderSearch ) as $orderItem ) {
99
+			foreach ($orderManager->searchItems($orderSearch) as $orderItem) {
100 100
 				$payStatus[$orderItem->getBaseId()] = $orderItem->getPaymentStatus();
101 101
 			}
102 102
 
103
-			foreach( $items as $item )
103
+			foreach ($items as $item)
104 104
 			{
105 105
 				try
106 106
 				{
107
-					if( isset( $payStatus[$item->getOrderBaseId()] ) && $payStatus[$item->getOrderBaseId()] >= $status )
107
+					if (isset($payStatus[$item->getOrderBaseId()]) && $payStatus[$item->getOrderBaseId()] >= $status)
108 108
 					{
109
-						foreach( $processors as $processor ) {
110
-							$processor->begin( $item );
109
+						foreach ($processors as $processor) {
110
+							$processor->begin($item);
111 111
 						}
112 112
 
113
-						$interval = new \DateInterval( $item->getInterval() );
114
-						$item->setDateNext( date_create( $item->getTimeCreated() )->add( $interval )->format( 'Y-m-d' ) );
113
+						$interval = new \DateInterval($item->getInterval());
114
+						$item->setDateNext(date_create($item->getTimeCreated())->add($interval)->format('Y-m-d'));
115 115
 					}
116 116
 					else
117 117
 					{
118
-						$item->setStatus( 0 );
118
+						$item->setStatus(0);
119 119
 					}
120 120
 
121
-					$manager->saveItem( $item );
121
+					$manager->saveItem($item);
122 122
 				}
123
-				catch( \Exception $e )
123
+				catch (\Exception $e)
124 124
 				{
125 125
 					$msg = 'Unable to process subscription with ID "%1$S": %2$s';
126
-					$logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) );
127
-					$logger->log( $e->getTraceAsString() );
126
+					$logger->log(sprintf($msg, $item->getId(), $e->getMessage()));
127
+					$logger->log($e->getTraceAsString());
128 128
 				}
129 129
 			}
130 130
 
131
-			$count = count( $items );
131
+			$count = count($items);
132 132
 			$start += $count;
133 133
 		}
134
-		while( $count === $search->getSliceSize() );
134
+		while ($count === $search->getSliceSize());
135 135
 	}
136 136
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -112,15 +112,13 @@
 block discarded – undo
112 112
 
113 113
 						$interval = new \DateInterval( $item->getInterval() );
114 114
 						$item->setDateNext( date_create( $item->getTimeCreated() )->add( $interval )->format( 'Y-m-d' ) );
115
-					}
116
-					else
115
+					} else
117 116
 					{
118 117
 						$item->setStatus( 0 );
119 118
 					}
120 119
 
121 120
 					$manager->saveItem( $item );
122
-				}
123
-				catch( \Exception $e )
121
+				} catch( \Exception $e )
124 122
 				{
125 123
 					$msg = 'Unable to process subscription with ID "%1$S": %2$s';
126 124
 					$logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) );
Please login to merge, or discard this patch.