@@ -35,51 +35,51 @@ |
||
| 35 | 35 | ); |
| 36 | 36 | |
| 37 | 37 | |
| 38 | - $object = new \Aimeos\Controller\Common\Order\Export\Csv\Processor\Product\Standard( $context, $mapping ); |
|
| 39 | - |
|
| 40 | - $invoice = $this->getInvoice( $context ); |
|
| 41 | - $order = \Aimeos\MShop\Factory::createManager( $context, 'order/base' )->load( $invoice->getBaseId() ); |
|
| 42 | - |
|
| 43 | - $data = $object->process( $invoice, $order ); |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - $this->assertEquals( 4, count( $data ) ); |
|
| 47 | - |
|
| 48 | - $this->assertEquals( 18, count( $data[0] ) ); |
|
| 49 | - $this->assertEquals( 'default', $data[0][0] ); |
|
| 50 | - $this->assertEquals( 'unit_type1', $data[0][1] ); |
|
| 51 | - $this->assertEquals( 'unitsupplier', $data[0][2] ); |
|
| 52 | - $this->assertEquals( 'CNE', $data[0][3] ); |
|
| 53 | - $this->assertGreaterThan( 0, $data[0][4] ); |
|
| 54 | - $this->assertEquals( '9', $data[0][5] ); |
|
| 55 | - $this->assertEquals( 'Cafe Noire Expresso', $data[0][6] ); |
|
| 56 | - $this->assertEquals( 'somewhere/thump1.jpg', $data[0][7] ); |
|
| 57 | - $this->assertEquals( '4.50', $data[0][8] ); |
|
| 58 | - $this->assertEquals( '0.00', $data[0][9] ); |
|
| 59 | - $this->assertEquals( '0.00', $data[0][10] ); |
|
| 60 | - $this->assertEquals( '0.0000', $data[0][11] ); |
|
| 61 | - $this->assertEquals( '1', $data[0][12] ); |
|
| 62 | - $this->assertEquals( '1', $data[0][13] ); |
|
| 63 | - $this->assertEquals( "default\ndefault\nsubscription", $data[0][14] ); |
|
| 64 | - $this->assertEquals( "width\nlength\ninterval", $data[0][15] ); |
|
| 65 | - $this->assertEquals( "33\n36\nP0Y1M0W0D", $data[0][16] ); |
|
| 66 | - $this->assertEquals( "33\n36\nP0Y1M0W0D", $data[0][17] ); |
|
| 38 | + $object = new \Aimeos\Controller\Common\Order\Export\Csv\Processor\Product\Standard($context, $mapping); |
|
| 39 | + |
|
| 40 | + $invoice = $this->getInvoice($context); |
|
| 41 | + $order = \Aimeos\MShop\Factory::createManager($context, 'order/base')->load($invoice->getBaseId()); |
|
| 42 | + |
|
| 43 | + $data = $object->process($invoice, $order); |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + $this->assertEquals(4, count($data)); |
|
| 47 | + |
|
| 48 | + $this->assertEquals(18, count($data[0])); |
|
| 49 | + $this->assertEquals('default', $data[0][0]); |
|
| 50 | + $this->assertEquals('unit_type1', $data[0][1]); |
|
| 51 | + $this->assertEquals('unitsupplier', $data[0][2]); |
|
| 52 | + $this->assertEquals('CNE', $data[0][3]); |
|
| 53 | + $this->assertGreaterThan(0, $data[0][4]); |
|
| 54 | + $this->assertEquals('9', $data[0][5]); |
|
| 55 | + $this->assertEquals('Cafe Noire Expresso', $data[0][6]); |
|
| 56 | + $this->assertEquals('somewhere/thump1.jpg', $data[0][7]); |
|
| 57 | + $this->assertEquals('4.50', $data[0][8]); |
|
| 58 | + $this->assertEquals('0.00', $data[0][9]); |
|
| 59 | + $this->assertEquals('0.00', $data[0][10]); |
|
| 60 | + $this->assertEquals('0.0000', $data[0][11]); |
|
| 61 | + $this->assertEquals('1', $data[0][12]); |
|
| 62 | + $this->assertEquals('1', $data[0][13]); |
|
| 63 | + $this->assertEquals("default\ndefault\nsubscription", $data[0][14]); |
|
| 64 | + $this->assertEquals("width\nlength\ninterval", $data[0][15]); |
|
| 65 | + $this->assertEquals("33\n36\nP0Y1M0W0D", $data[0][16]); |
|
| 66 | + $this->assertEquals("33\n36\nP0Y1M0W0D", $data[0][17]); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | |
| 70 | - protected function getInvoice( $context ) |
|
| 70 | + protected function getInvoice($context) |
|
| 71 | 71 | { |
| 72 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'order' ); |
|
| 72 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'order'); |
|
| 73 | 73 | |
| 74 | 74 | $search = $manager->createSearch(); |
| 75 | - $search->setConditions( $search->compare( '==', 'order.datepayment', '2008-02-15 12:34:56' ) ); |
|
| 75 | + $search->setConditions($search->compare('==', 'order.datepayment', '2008-02-15 12:34:56')); |
|
| 76 | 76 | |
| 77 | - $items = $manager->searchItems( $search ); |
|
| 77 | + $items = $manager->searchItems($search); |
|
| 78 | 78 | |
| 79 | - if( ( $item = reset( $items ) ) !== false ) { |
|
| 79 | + if (($item = reset($items)) !== false) { |
|
| 80 | 80 | return $item; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - throw new \Exception( 'No order item found' ); |
|
| 83 | + throw new \Exception('No order item found'); |
|
| 84 | 84 | } |
| 85 | 85 | } |
@@ -12,13 +12,13 @@ discard block |
||
| 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,29 +26,29 @@ discard block |
||
| 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( |
|
| 45 | - function( $subject ){ |
|
| 43 | + $customerStub->expects($this->once())->method('saveItem') |
|
| 44 | + ->with($this->callback( |
|
| 45 | + function($subject) { |
|
| 46 | 46 | return $subject->getGroups() === ['1', '2']; |
| 47 | 47 | } |
| 48 | - ) ); |
|
| 48 | + )); |
|
| 49 | 49 | |
| 50 | - $object = new \Aimeos\Controller\Common\Subscription\Process\Processor\Cgroup\Standard( $context ); |
|
| 51 | - $object->begin( $this->getSubscription( $context ) ); |
|
| 50 | + $object = new \Aimeos\Controller\Common\Subscription\Process\Processor\Cgroup\Standard($context); |
|
| 51 | + $object->begin($this->getSubscription($context)); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | |
@@ -56,45 +56,45 @@ discard block |
||
| 56 | 56 | { |
| 57 | 57 | $context = \TestHelperCntl::getContext(); |
| 58 | 58 | |
| 59 | - $context->getConfig()->set( 'controller/common/subscription/process/processor/cgroup/groupids', ['1', '2'] ); |
|
| 59 | + $context->getConfig()->set('controller/common/subscription/process/processor/cgroup/groupids', ['1', '2']); |
|
| 60 | 60 | |
| 61 | - $customerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Customer\\Manager\\Standard' ) |
|
| 62 | - ->setConstructorArgs( [$context] ) |
|
| 63 | - ->setMethods( ['getItem', 'saveItem'] ) |
|
| 61 | + $customerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Customer\\Manager\\Standard') |
|
| 62 | + ->setConstructorArgs([$context]) |
|
| 63 | + ->setMethods(['getItem', 'saveItem']) |
|
| 64 | 64 | ->getMock(); |
| 65 | 65 | |
| 66 | - \Aimeos\MShop\Factory::injectManager( $context, 'customer', $customerStub ); |
|
| 66 | + \Aimeos\MShop\Factory::injectManager($context, 'customer', $customerStub); |
|
| 67 | 67 | |
| 68 | - $customerItem = $customerStub->createItem()->setGroups( ['1', '2'] ); |
|
| 68 | + $customerItem = $customerStub->createItem()->setGroups(['1', '2']); |
|
| 69 | 69 | |
| 70 | - $customerStub->expects( $this->once() )->method( 'getItem' ) |
|
| 71 | - ->will( $this->returnValue( $customerItem ) ); |
|
| 70 | + $customerStub->expects($this->once())->method('getItem') |
|
| 71 | + ->will($this->returnValue($customerItem)); |
|
| 72 | 72 | |
| 73 | - $customerStub->expects( $this->once() )->method( 'saveItem' ) |
|
| 74 | - ->with( $this->callback( |
|
| 75 | - function( $subject ){ |
|
| 73 | + $customerStub->expects($this->once())->method('saveItem') |
|
| 74 | + ->with($this->callback( |
|
| 75 | + function($subject) { |
|
| 76 | 76 | return $subject->getGroups() === []; |
| 77 | 77 | } |
| 78 | - ) ); |
|
| 78 | + )); |
|
| 79 | 79 | |
| 80 | - $object = new \Aimeos\Controller\Common\Subscription\Process\Processor\Cgroup\Standard( $context ); |
|
| 81 | - $object->end( $this->getSubscription( $context ) ); |
|
| 80 | + $object = new \Aimeos\Controller\Common\Subscription\Process\Processor\Cgroup\Standard($context); |
|
| 81 | + $object->end($this->getSubscription($context)); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | |
| 85 | - protected function getSubscription( $context ) |
|
| 85 | + protected function getSubscription($context) |
|
| 86 | 86 | { |
| 87 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'subscription' ); |
|
| 87 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'subscription'); |
|
| 88 | 88 | |
| 89 | 89 | $search = $manager->createSearch(); |
| 90 | - $search->setConditions( $search->compare( '==', 'subscription.dateend', '2010-01-01' ) ); |
|
| 90 | + $search->setConditions($search->compare('==', 'subscription.dateend', '2010-01-01')); |
|
| 91 | 91 | |
| 92 | - $items = $manager->searchItems( $search ); |
|
| 92 | + $items = $manager->searchItems($search); |
|
| 93 | 93 | |
| 94 | - if( ( $item = reset( $items ) ) !== false ) { |
|
| 94 | + if (($item = reset($items)) !== false) { |
|
| 95 | 95 | return $item; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - throw new \Exception( 'No subscription item found' ); |
|
| 98 | + throw new \Exception('No subscription item found'); |
|
| 99 | 99 | } |
| 100 | 100 | } |
@@ -35,51 +35,51 @@ |
||
| 35 | 35 | ); |
| 36 | 36 | |
| 37 | 37 | |
| 38 | - $object = new \Aimeos\Controller\Common\Subscription\Export\Csv\Processor\Product\Standard( $context, $mapping ); |
|
| 39 | - |
|
| 40 | - $subscription = $this->getSubscription( $context ); |
|
| 41 | - $order = \Aimeos\MShop\Factory::createManager( $context, 'order/base' )->load( $subscription->getOrderBaseId() ); |
|
| 42 | - |
|
| 43 | - $data = $object->process( $subscription, $order ); |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - $this->assertEquals( 1, count( $data ) ); |
|
| 47 | - |
|
| 48 | - $this->assertEquals( 18, count( $data[0] ) ); |
|
| 49 | - $this->assertEquals( 'default', $data[0][0] ); |
|
| 50 | - $this->assertEquals( 'unit_type1', $data[0][1] ); |
|
| 51 | - $this->assertEquals( 'unitsupplier', $data[0][2] ); |
|
| 52 | - $this->assertEquals( 'CNE', $data[0][3] ); |
|
| 53 | - $this->assertGreaterThan( 0, $data[0][4] ); |
|
| 54 | - $this->assertEquals( '9', $data[0][5] ); |
|
| 55 | - $this->assertEquals( 'Cafe Noire Expresso', $data[0][6] ); |
|
| 56 | - $this->assertEquals( 'somewhere/thump1.jpg', $data[0][7] ); |
|
| 57 | - $this->assertEquals( '4.50', $data[0][8] ); |
|
| 58 | - $this->assertEquals( '0.00', $data[0][9] ); |
|
| 59 | - $this->assertEquals( '0.00', $data[0][10] ); |
|
| 60 | - $this->assertEquals( '0.0000', $data[0][11] ); |
|
| 61 | - $this->assertEquals( '1', $data[0][12] ); |
|
| 62 | - $this->assertEquals( '1', $data[0][13] ); |
|
| 63 | - $this->assertEquals( "default\ndefault\nsubscription", $data[0][14] ); |
|
| 64 | - $this->assertEquals( "width\nlength\ninterval", $data[0][15] ); |
|
| 65 | - $this->assertEquals( "33\n36\nP0Y1M0W0D", $data[0][16] ); |
|
| 66 | - $this->assertEquals( "33\n36\nP0Y1M0W0D", $data[0][17] ); |
|
| 38 | + $object = new \Aimeos\Controller\Common\Subscription\Export\Csv\Processor\Product\Standard($context, $mapping); |
|
| 39 | + |
|
| 40 | + $subscription = $this->getSubscription($context); |
|
| 41 | + $order = \Aimeos\MShop\Factory::createManager($context, 'order/base')->load($subscription->getOrderBaseId()); |
|
| 42 | + |
|
| 43 | + $data = $object->process($subscription, $order); |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + $this->assertEquals(1, count($data)); |
|
| 47 | + |
|
| 48 | + $this->assertEquals(18, count($data[0])); |
|
| 49 | + $this->assertEquals('default', $data[0][0]); |
|
| 50 | + $this->assertEquals('unit_type1', $data[0][1]); |
|
| 51 | + $this->assertEquals('unitsupplier', $data[0][2]); |
|
| 52 | + $this->assertEquals('CNE', $data[0][3]); |
|
| 53 | + $this->assertGreaterThan(0, $data[0][4]); |
|
| 54 | + $this->assertEquals('9', $data[0][5]); |
|
| 55 | + $this->assertEquals('Cafe Noire Expresso', $data[0][6]); |
|
| 56 | + $this->assertEquals('somewhere/thump1.jpg', $data[0][7]); |
|
| 57 | + $this->assertEquals('4.50', $data[0][8]); |
|
| 58 | + $this->assertEquals('0.00', $data[0][9]); |
|
| 59 | + $this->assertEquals('0.00', $data[0][10]); |
|
| 60 | + $this->assertEquals('0.0000', $data[0][11]); |
|
| 61 | + $this->assertEquals('1', $data[0][12]); |
|
| 62 | + $this->assertEquals('1', $data[0][13]); |
|
| 63 | + $this->assertEquals("default\ndefault\nsubscription", $data[0][14]); |
|
| 64 | + $this->assertEquals("width\nlength\ninterval", $data[0][15]); |
|
| 65 | + $this->assertEquals("33\n36\nP0Y1M0W0D", $data[0][16]); |
|
| 66 | + $this->assertEquals("33\n36\nP0Y1M0W0D", $data[0][17]); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | |
| 70 | - protected function getSubscription( $context ) |
|
| 70 | + protected function getSubscription($context) |
|
| 71 | 71 | { |
| 72 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'subscription' ); |
|
| 72 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'subscription'); |
|
| 73 | 73 | |
| 74 | 74 | $search = $manager->createSearch(); |
| 75 | - $search->setConditions( $search->compare( '==', 'subscription.dateend', '2010-01-01' ) ); |
|
| 75 | + $search->setConditions($search->compare('==', 'subscription.dateend', '2010-01-01')); |
|
| 76 | 76 | |
| 77 | - $items = $manager->searchItems( $search ); |
|
| 77 | + $items = $manager->searchItems($search); |
|
| 78 | 78 | |
| 79 | - if( ( $item = reset( $items ) ) !== false ) { |
|
| 79 | + if (($item = reset($items)) !== false) { |
|
| 80 | 80 | return $item; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - throw new \Exception( 'No subscription item found' ); |
|
| 83 | + throw new \Exception('No subscription item found'); |
|
| 84 | 84 | } |
| 85 | 85 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
| 26 | 26 | */ |
| 27 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ); |
|
| 27 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context); |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @param \Aimeos\MShop\Subscription\Item\Iface $subscription Subscription item |
| 34 | 34 | */ |
| 35 | - public function begin( \Aimeos\MShop\Subscription\Item\Iface $subscription ); |
|
| 35 | + public function begin(\Aimeos\MShop\Subscription\Item\Iface $subscription); |
|
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @param \Aimeos\MShop\Subscription\Item\Iface $subscription Subscription item |
| 42 | 42 | */ |
| 43 | - public function renew( \Aimeos\MShop\Subscription\Item\Iface $subscription ); |
|
| 43 | + public function renew(\Aimeos\MShop\Subscription\Item\Iface $subscription); |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -48,5 +48,5 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @param \Aimeos\MShop\Subscription\Item\Iface $subscription Subscription item |
| 50 | 50 | */ |
| 51 | - public function end( \Aimeos\MShop\Subscription\Item\Iface $subscription ); |
|
| 51 | + public function end(\Aimeos\MShop\Subscription\Item\Iface $subscription); |
|
| 52 | 52 | } |
| 53 | 53 | \ No newline at end of file |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
| 42 | 42 | */ |
| 43 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 43 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 44 | 44 | { |
| 45 | - parent::__construct( $context ); |
|
| 45 | + parent::__construct($context); |
|
| 46 | 46 | |
| 47 | 47 | $config = $context->getConfig(); |
| 48 | 48 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @since 2018.04 |
| 58 | 58 | * @category Developer |
| 59 | 59 | */ |
| 60 | - $this->groupIds = (array) $config->get( 'controller/common/subscription/process/processor/cgroup/groupids', [] ); |
|
| 60 | + $this->groupIds = (array) $config->get('controller/common/subscription/process/processor/cgroup/groupids', []); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | |
@@ -66,22 +66,22 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @param \Aimeos\MShop\Subscription\Item\Iface $subscription Subscription item |
| 68 | 68 | */ |
| 69 | - public function begin( \Aimeos\MShop\Subscription\Item\Iface $subscription ) |
|
| 69 | + public function begin(\Aimeos\MShop\Subscription\Item\Iface $subscription) |
|
| 70 | 70 | { |
| 71 | - if( empty( $this->groupIds ) ) { |
|
| 71 | + if (empty($this->groupIds)) { |
|
| 72 | 72 | return; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $context = $this->getContext(); |
| 76 | 76 | |
| 77 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' ); |
|
| 78 | - $baseManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
| 77 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer'); |
|
| 78 | + $baseManager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
| 79 | 79 | |
| 80 | - $baseItem = $baseManager->getItem( $subscription->getOrderBaseId() ); |
|
| 81 | - $item = $manager->getItem( $baseItem->getCustomerId(), ['customer/group'] ); |
|
| 80 | + $baseItem = $baseManager->getItem($subscription->getOrderBaseId()); |
|
| 81 | + $item = $manager->getItem($baseItem->getCustomerId(), ['customer/group']); |
|
| 82 | 82 | |
| 83 | - $item->setGroups( array_unique( array_merge( $item->getGroups(), $this->groupIds ) ) ); |
|
| 84 | - $manager->saveItem( $item ); |
|
| 83 | + $item->setGroups(array_unique(array_merge($item->getGroups(), $this->groupIds))); |
|
| 84 | + $manager->saveItem($item); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | |
@@ -90,21 +90,21 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @param \Aimeos\MShop\Subscription\Item\Iface $subscription Subscription item |
| 92 | 92 | */ |
| 93 | - public function end( \Aimeos\MShop\Subscription\Item\Iface $subscription ) |
|
| 93 | + public function end(\Aimeos\MShop\Subscription\Item\Iface $subscription) |
|
| 94 | 94 | { |
| 95 | - if( empty( $this->groupIds ) ) { |
|
| 95 | + if (empty($this->groupIds)) { |
|
| 96 | 96 | return; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $context = $this->getContext(); |
| 100 | 100 | |
| 101 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' ); |
|
| 102 | - $baseManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
| 101 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer'); |
|
| 102 | + $baseManager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
| 103 | 103 | |
| 104 | - $baseItem = $baseManager->getItem( $subscription->getOrderBaseId() ); |
|
| 105 | - $item = $manager->getItem( $baseItem->getCustomerId(), ['customer/group'] ); |
|
| 104 | + $baseItem = $baseManager->getItem($subscription->getOrderBaseId()); |
|
| 105 | + $item = $manager->getItem($baseItem->getCustomerId(), ['customer/group']); |
|
| 106 | 106 | |
| 107 | - $item->setGroups( array_diff( $item->getGroups(), $this->groupIds ) ); |
|
| 108 | - $manager->saveItem( $item ); |
|
| 107 | + $item->setGroups(array_diff($item->getGroups(), $this->groupIds)); |
|
| 108 | + $manager->saveItem($item); |
|
| 109 | 109 | } |
| 110 | 110 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
| 29 | 29 | */ |
| 30 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 30 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 31 | 31 | { |
| 32 | 32 | $this->context = $context; |
| 33 | 33 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * |
| 50 | 50 | * @param \Aimeos\MShop\Subscription\Item\Iface $subscription Subscription item |
| 51 | 51 | */ |
| 52 | - public function begin( \Aimeos\MShop\Subscription\Item\Iface $subscription ) |
|
| 52 | + public function begin(\Aimeos\MShop\Subscription\Item\Iface $subscription) |
|
| 53 | 53 | { |
| 54 | 54 | } |
| 55 | 55 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @param \Aimeos\MShop\Subscription\Item\Iface $subscription Subscription item |
| 61 | 61 | */ |
| 62 | - public function renew( \Aimeos\MShop\Subscription\Item\Iface $subscription ) |
|
| 62 | + public function renew(\Aimeos\MShop\Subscription\Item\Iface $subscription) |
|
| 63 | 63 | { |
| 64 | 64 | } |
| 65 | 65 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @param \Aimeos\MShop\Subscription\Item\Iface $subscription Subscription item |
| 71 | 71 | */ |
| 72 | - public function end( \Aimeos\MShop\Subscription\Item\Iface $subscription ) |
|
| 72 | + public function end(\Aimeos\MShop\Subscription\Item\Iface $subscription) |
|
| 73 | 73 | { |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -20,30 +20,30 @@ discard block |
||
| 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 | |
@@ -51,17 +51,17 @@ discard block |
||
| 51 | 51 | { |
| 52 | 52 | $item = $this->getSubscription(); |
| 53 | 53 | |
| 54 | - $managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' ) |
|
| 55 | - ->setConstructorArgs( [$this->context] ) |
|
| 56 | - ->setMethods( ['searchItems', 'saveItem'] ) |
|
| 54 | + $managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard') |
|
| 55 | + ->setConstructorArgs([$this->context]) |
|
| 56 | + ->setMethods(['searchItems', 'saveItem']) |
|
| 57 | 57 | ->getMock(); |
| 58 | 58 | |
| 59 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'subscription', $managerStub ); |
|
| 59 | + \Aimeos\MShop\Factory::injectManager($this->context, 'subscription', $managerStub); |
|
| 60 | 60 | |
| 61 | - $managerStub->expects( $this->once() )->method( 'searchItems' ) |
|
| 62 | - ->will( $this->returnValue( [$item] ) ); |
|
| 61 | + $managerStub->expects($this->once())->method('searchItems') |
|
| 62 | + ->will($this->returnValue([$item])); |
|
| 63 | 63 | |
| 64 | - $managerStub->expects( $this->once() )->method( 'saveItem' ); |
|
| 64 | + $managerStub->expects($this->once())->method('saveItem'); |
|
| 65 | 65 | |
| 66 | 66 | $this->object->run(); |
| 67 | 67 | } |
@@ -71,18 +71,18 @@ discard block |
||
| 71 | 71 | { |
| 72 | 72 | $item = $this->getSubscription(); |
| 73 | 73 | |
| 74 | - $managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' ) |
|
| 75 | - ->setConstructorArgs( [$this->context] ) |
|
| 76 | - ->setMethods( ['searchItems', 'saveItem'] ) |
|
| 74 | + $managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard') |
|
| 75 | + ->setConstructorArgs([$this->context]) |
|
| 76 | + ->setMethods(['searchItems', 'saveItem']) |
|
| 77 | 77 | ->getMock(); |
| 78 | 78 | |
| 79 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'subscription', $managerStub ); |
|
| 79 | + \Aimeos\MShop\Factory::injectManager($this->context, 'subscription', $managerStub); |
|
| 80 | 80 | |
| 81 | - $managerStub->expects( $this->once() )->method( 'searchItems' ) |
|
| 82 | - ->will( $this->returnValue( [$item] ) ); |
|
| 81 | + $managerStub->expects($this->once())->method('searchItems') |
|
| 82 | + ->will($this->returnValue([$item])); |
|
| 83 | 83 | |
| 84 | - $managerStub->expects( $this->once() )->method( 'saveItem' ) |
|
| 85 | - ->will( $this->throwException( new \Exception() ) ); |
|
| 84 | + $managerStub->expects($this->once())->method('saveItem') |
|
| 85 | + ->will($this->throwException(new \Exception())); |
|
| 86 | 86 | |
| 87 | 87 | $this->object->run(); |
| 88 | 88 | } |
@@ -90,17 +90,17 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | protected function getSubscription() |
| 92 | 92 | { |
| 93 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'subscription' ); |
|
| 93 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'subscription'); |
|
| 94 | 94 | |
| 95 | 95 | $search = $manager->createSearch(); |
| 96 | - $search->setConditions( $search->compare( '==', 'subscription.dateend', '2010-01-01' ) ); |
|
| 96 | + $search->setConditions($search->compare('==', 'subscription.dateend', '2010-01-01')); |
|
| 97 | 97 | |
| 98 | - $items = $manager->searchItems( $search ); |
|
| 98 | + $items = $manager->searchItems($search); |
|
| 99 | 99 | |
| 100 | - if( ( $item = reset( $items ) ) !== false ) { |
|
| 100 | + if (($item = reset($items)) !== false) { |
|
| 101 | 101 | return $item; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - throw new \Exception( 'No subscription item found' ); |
|
| 104 | + throw new \Exception('No subscription item found'); |
|
| 105 | 105 | } |
| 106 | 106 | } |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | $context = \TestHelperJobs::getContext(); |
| 17 | 17 | $aimeos = \TestHelperJobs::getAimeos(); |
| 18 | 18 | |
| 19 | - $obj = \Aimeos\Controller\Jobs\Subscription\Process\Begin\Factory::createController( $context, $aimeos ); |
|
| 20 | - $this->assertInstanceOf( '\\Aimeos\\Controller\\Jobs\\Iface', $obj ); |
|
| 19 | + $obj = \Aimeos\Controller\Jobs\Subscription\Process\Begin\Factory::createController($context, $aimeos); |
|
| 20 | + $this->assertInstanceOf('\\Aimeos\\Controller\\Jobs\\Iface', $obj); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | $context = \TestHelperJobs::getContext(); |
| 27 | 27 | $aimeos = \TestHelperJobs::getAimeos(); |
| 28 | 28 | |
| 29 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
| 30 | - \Aimeos\Controller\Jobs\Subscription\Process\Begin\Factory::createController( $context, $aimeos, 'Wrong$$$Name' ); |
|
| 29 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
| 30 | + \Aimeos\Controller\Jobs\Subscription\Process\Begin\Factory::createController($context, $aimeos, 'Wrong$$$Name'); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | |
@@ -36,8 +36,8 @@ discard block |
||
| 36 | 36 | $context = \TestHelperJobs::getContext(); |
| 37 | 37 | $aimeos = \TestHelperJobs::getAimeos(); |
| 38 | 38 | |
| 39 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
| 40 | - \Aimeos\Controller\Jobs\Subscription\Process\Begin\Factory::createController( $context, $aimeos, 'WrongClass' ); |
|
| 39 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
| 40 | + \Aimeos\Controller\Jobs\Subscription\Process\Begin\Factory::createController($context, $aimeos, 'WrongClass'); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | $context = \TestHelperJobs::getContext(); |
| 47 | 47 | $aimeos = \TestHelperJobs::getAimeos(); |
| 48 | 48 | |
| 49 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
| 50 | - \Aimeos\Controller\Jobs\Subscription\Process\Begin\Factory::createController( $context, $aimeos, 'Factory' ); |
|
| 49 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
| 50 | + \Aimeos\Controller\Jobs\Subscription\Process\Begin\Factory::createController($context, $aimeos, 'Factory'); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 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 |
||
| 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,50 +65,50 @@ discard block |
||
| 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 | echo $e->getMessage() . PHP_EOL; |
| 104 | 104 | $msg = 'Unable to process subscription with ID "%1$S": %2$s'; |
| 105 | - $logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) ); |
|
| 105 | + $logger->log(sprintf($msg, $item->getId(), $e->getMessage())); |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - $count = count( $items ); |
|
| 109 | + $count = count($items); |
|
| 110 | 110 | $start += $count; |
| 111 | 111 | } |
| 112 | - while( $count === $search->getSliceSize() ); |
|
| 112 | + while ($count === $search->getSliceSize()); |
|
| 113 | 113 | } |
| 114 | 114 | } |
@@ -97,8 +97,7 @@ |
||
| 97 | 97 | $item->setDateNext( date_create( $item->getTimeCreated() )->add( $interval )->format( 'Y-m-d' ) ); |
| 98 | 98 | |
| 99 | 99 | $manager->saveItem( $item ); |
| 100 | - } |
|
| 101 | - catch( \Exception $e ) |
|
| 100 | + } catch( \Exception $e ) |
|
| 102 | 101 | { |
| 103 | 102 | echo $e->getMessage() . PHP_EOL; |
| 104 | 103 | $msg = 'Unable to process subscription with ID "%1$S": %2$s'; |