Completed
Push — master ( 6c75b7...90deda )
by Aimeos
15:40 queued 12:37
created
controller/jobs/src/Controller/Jobs/Subscription/Process/Begin/Standard.php 1 patch
Spacing   +21 added lines, -21 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,49 +65,49 @@  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
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'subscription' );
70
+		$processors = $this->getProcessors($names);
71
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'subscription');
72 72
 
73
-		$search = $manager->createSearch( true );
73
+		$search = $manager->createSearch(true);
74 74
 		$expr = [
75
-			$search->compare( '==', 'subscription.datenext', null ),
75
+			$search->compare('==', 'subscription.datenext', null),
76 76
 			$search->getConditions(),
77 77
 		];
78
-		$search->setConditions( $search->combine( '&&', $expr ) );
79
-		$search->setSortations( [$search->sort( '+', 'subscription.id' )] );
78
+		$search->setConditions($search->combine('&&', $expr));
79
+		$search->setSortations([$search->sort('+', 'subscription.id')]);
80 80
 
81 81
 		$start = 0;
82 82
 
83 83
 		do
84 84
 		{
85
-			$search->setSlice( $start, 100 );
86
-			$items = $manager->searchItems( $search );
85
+			$search->setSlice($start, 100);
86
+			$items = $manager->searchItems($search);
87 87
 
88
-			foreach( $items as $item )
88
+			foreach ($items as $item)
89 89
 			{
90 90
 				try
91 91
 				{
92
-					foreach( $processors as $processor ) {
93
-						$processor->begin( $item );
92
+					foreach ($processors as $processor) {
93
+						$processor->begin($item);
94 94
 					}
95 95
 
96
-					$interval = \DateInterval::createFromDateString( $item->getInterval() );
97
-					$item->setDateNext( date_create( $item->getTimeCreated() )->add( $interval )->format( 'Y-m-d' ) );
96
+					$interval = \DateInterval::createFromDateString($item->getInterval());
97
+					$item->setDateNext(date_create($item->getTimeCreated())->add($interval)->format('Y-m-d'));
98 98
 
99
-					$manager->saveItem( $item );
99
+					$manager->saveItem($item);
100 100
 				}
101
-				catch( \Exception $e )
101
+				catch (\Exception $e)
102 102
 				{
103 103
 					$msg = 'Unable to process subscription with ID "%1$S": %2$s';
104
-					$logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) );
104
+					$logger->log(sprintf($msg, $item->getId(), $e->getMessage()));
105 105
 				}
106 106
 			}
107 107
 
108
-			$count = count( $items );
108
+			$count = count($items);
109 109
 			$start += $count;
110 110
 		}
111
-		while( $count === $search->getSliceSize() );
111
+		while ($count === $search->getSliceSize());
112 112
 	}
113 113
 }
Please login to merge, or discard this patch.
Controller/Common/Subscription/Process/Processor/Cgroup/StandardTest.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@  discard block
 block discarded – undo
12 12
 {
13 13
 	protected function setUp()
14 14
 	{
15
-		\Aimeos\MShop\Factory::setCache( true );
15
+		\Aimeos\MShop\Factory::setCache(true);
16 16
 	}
17 17
 
18 18
 
19 19
 	protected function tearDown()
20 20
 	{
21
-		\Aimeos\MShop\Factory::setCache( false );
21
+		\Aimeos\MShop\Factory::setCache(false);
22 22
 	}
23 23
 
24 24
 
@@ -26,27 +26,27 @@  discard block
 block discarded – undo
26 26
 	{
27 27
 		$context = \TestHelperCntl::getContext();
28 28
 
29
-		$context->getConfig()->set( 'controller/common/subscription/process/processor/cgroup/groupids', ['1', '2'] );
29
+		$context->getConfig()->set('controller/common/subscription/process/processor/cgroup/groupids', ['1', '2']);
30 30
 
31
-		$customerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Customer\\Manager\\Standard' )
32
-			->setConstructorArgs( [$context] )
33
-			->setMethods( ['getItem', 'saveItem'] )
31
+		$customerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Customer\\Manager\\Standard')
32
+			->setConstructorArgs([$context])
33
+			->setMethods(['getItem', 'saveItem'])
34 34
 			->getMock();
35 35
 
36
-		\Aimeos\MShop\Factory::injectManager( $context, 'customer', $customerStub );
36
+		\Aimeos\MShop\Factory::injectManager($context, 'customer', $customerStub);
37 37
 
38 38
 		$customerItem = $customerStub->createItem();
39 39
 
40
-		$customerStub->expects( $this->once() )->method( 'getItem' )
41
-			->will( $this->returnValue( $customerItem ) );
40
+		$customerStub->expects($this->once())->method('getItem')
41
+			->will($this->returnValue($customerItem));
42 42
 
43
-		$customerStub->expects( $this->once() )->method( 'saveItem' )
44
-			->with( $this->callback( function( $subject ){
43
+		$customerStub->expects($this->once())->method('saveItem')
44
+			->with($this->callback(function($subject) {
45 45
 				return $subject->getGroups() === ['1', '2'];
46
-			} ) );
46
+			} ));
47 47
 
48
-		$object = new \Aimeos\Controller\Common\Subscription\Process\Processor\Cgroup\Standard( $context );
49
-		$object->begin( $this->getSubscription( $context ) );
48
+		$object = new \Aimeos\Controller\Common\Subscription\Process\Processor\Cgroup\Standard($context);
49
+		$object->begin($this->getSubscription($context));
50 50
 	}
51 51
 
52 52
 
@@ -54,43 +54,43 @@  discard block
 block discarded – undo
54 54
 	{
55 55
 		$context = \TestHelperCntl::getContext();
56 56
 
57
-		$context->getConfig()->set( 'controller/common/subscription/process/processor/cgroup/groupids', ['1', '2'] );
57
+		$context->getConfig()->set('controller/common/subscription/process/processor/cgroup/groupids', ['1', '2']);
58 58
 
59
-		$customerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Customer\\Manager\\Standard' )
60
-			->setConstructorArgs( [$context] )
61
-			->setMethods( ['getItem', 'saveItem'] )
59
+		$customerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Customer\\Manager\\Standard')
60
+			->setConstructorArgs([$context])
61
+			->setMethods(['getItem', 'saveItem'])
62 62
 			->getMock();
63 63
 
64
-		\Aimeos\MShop\Factory::injectManager( $context, 'customer', $customerStub );
64
+		\Aimeos\MShop\Factory::injectManager($context, 'customer', $customerStub);
65 65
 
66
-		$customerItem = $customerStub->createItem()->setGroups( ['1', '2'] );
66
+		$customerItem = $customerStub->createItem()->setGroups(['1', '2']);
67 67
 
68
-		$customerStub->expects( $this->once() )->method( 'getItem' )
69
-			->will( $this->returnValue( $customerItem ) );
68
+		$customerStub->expects($this->once())->method('getItem')
69
+			->will($this->returnValue($customerItem));
70 70
 
71
-		$customerStub->expects( $this->once() )->method( 'saveItem' )
72
-			->with( $this->callback( function( $subject ){
71
+		$customerStub->expects($this->once())->method('saveItem')
72
+			->with($this->callback(function($subject) {
73 73
 				return $subject->getGroups() === [];
74
-			} ) );
74
+			} ));
75 75
 
76
-		$object = new \Aimeos\Controller\Common\Subscription\Process\Processor\Cgroup\Standard( $context );
77
-		$object->end( $this->getSubscription( $context ) );
76
+		$object = new \Aimeos\Controller\Common\Subscription\Process\Processor\Cgroup\Standard($context);
77
+		$object->end($this->getSubscription($context));
78 78
 	}
79 79
 
80 80
 
81
-	protected function getSubscription( $context )
81
+	protected function getSubscription($context)
82 82
 	{
83
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'subscription' );
83
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'subscription');
84 84
 
85 85
 		$search = $manager->createSearch();
86
-		$search->setConditions( $search->compare( '==', 'subscription.dateend', '2010-01-01' ) );
86
+		$search->setConditions($search->compare('==', 'subscription.dateend', '2010-01-01'));
87 87
 
88
-		$items = $manager->searchItems( $search );
88
+		$items = $manager->searchItems($search);
89 89
 
90
-		if( ( $item = reset( $items ) ) !== false ) {
90
+		if (($item = reset($items)) !== false) {
91 91
 			return $item;
92 92
 		}
93 93
 
94
-		throw new \Exception( 'No subscription item found' );
94
+		throw new \Exception('No subscription item found');
95 95
 	}
96 96
 }
Please login to merge, or discard this patch.