| @@ -29,7 +29,7 @@ | ||
| 29 | 29 | * Initializes the object | 
| 30 | 30 | * | 
| 31 | 31 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object | 
| 32 | - * @param array $mapping Associative list of field position in CSV as key and domain item key as value | |
| 32 | + * @param string[] $mapping Associative list of field position in CSV as key and domain item key as value | |
| 33 | 33 | * @param \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object Decorated processor | 
| 34 | 34 | */ | 
| 35 | 35 | public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, | 
| @@ -32,8 +32,8 @@ discard block | ||
| 32 | 32 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value | 
| 33 | 33 | * @param \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object Decorated processor | 
| 34 | 34 | */ | 
| 35 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, | |
| 36 | - \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object = null ) | |
| 35 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, | |
| 36 | + \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object = null) | |
| 37 | 37 |  	{ | 
| 38 | 38 | $this->context = $context; | 
| 39 | 39 | $this->mapping = $mapping; | 
| @@ -71,8 +71,8 @@ discard block | ||
| 71 | 71 | */ | 
| 72 | 72 | protected function getObject() | 
| 73 | 73 |  	{ | 
| 74 | -		if( $this->object === null ) { | |
| 75 | - throw new \Aimeos\Controller\Jobs\Exception( 'No processor object available' ); | |
| 74 | +		if ($this->object === null) { | |
| 75 | +			throw new \Aimeos\Controller\Jobs\Exception('No processor object available'); | |
| 76 | 76 | } | 
| 77 | 77 | |
| 78 | 78 | return $this->object; | 
| @@ -26,17 +26,17 @@ discard block | ||
| 26 | 26 | * @param array $codes List of coupon codes | 
| 27 | 27 | * @return array Associative list of coupon codes as key and coupon code items as value | 
| 28 | 28 | */ | 
| 29 | - protected function getCouponCodeItems( array $codes ) | |
| 29 | + protected function getCouponCodeItems(array $codes) | |
| 30 | 30 |  	{ | 
| 31 | 31 | $result = []; | 
| 32 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon/code' ); | |
| 32 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon/code'); | |
| 33 | 33 | |
| 34 | 34 | $search = $manager->createSearch(); | 
| 35 | - $search->setConditions( $search->compare( '==', 'coupon.code.code', $codes ) ); | |
| 36 | - $search->setSlice( 0, count( $codes ) ); | |
| 35 | +		$search->setConditions($search->compare('==', 'coupon.code.code', $codes)); | |
| 36 | + $search->setSlice(0, count($codes)); | |
| 37 | 37 | |
| 38 | -		foreach( $manager->searchItems( $search ) as $item ) { | |
| 39 | - $result[ $item->getCode() ] = $item; | |
| 38 | +		foreach ($manager->searchItems($search) as $item) { | |
| 39 | + $result[$item->getCode()] = $item; | |
| 40 | 40 | } | 
| 41 | 41 | |
| 42 | 42 | return $result; | 
| @@ -51,15 +51,15 @@ discard block | ||
| 51 | 51 | * @param integer $codePos Column position which contains the unique coupon code (starting from 0) | 
| 52 | 52 | * @return array List of arrays with coupon codes as keys and list of values from the CSV file | 
| 53 | 53 | */ | 
| 54 | - protected function getData( \Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos ) | |
| 54 | + protected function getData(\Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos) | |
| 55 | 55 |  	{ | 
| 56 | 56 | $count = 0; | 
| 57 | 57 | $data = []; | 
| 58 | 58 | |
| 59 | - while( $content->valid() && $count++ < $maxcnt ) | |
| 59 | + while ($content->valid() && $count++ < $maxcnt) | |
| 60 | 60 |  		{ | 
| 61 | 61 | $row = $content->current(); | 
| 62 | - $data[ $row[$codePos] ] = $row; | |
| 62 | + $data[$row[$codePos]] = $row; | |
| 63 | 63 | $content->next(); | 
| 64 | 64 | } | 
| 65 | 65 | |
| @@ -98,21 +98,21 @@ discard block | ||
| 98 | 98 | * @param array $mapping List of domain item keys with the CSV field position as key | 
| 99 | 99 | * @return array List of associative arrays containing the chunked properties | 
| 100 | 100 | */ | 
| 101 | - protected function getMappedChunk( array &$data, array $mapping ) | |
| 101 | + protected function getMappedChunk(array &$data, array $mapping) | |
| 102 | 102 |  	{ | 
| 103 | 103 | $idx = 0; | 
| 104 | 104 | $map = []; | 
| 105 | 105 | |
| 106 | - foreach( $mapping as $pos => $key ) | |
| 106 | + foreach ($mapping as $pos => $key) | |
| 107 | 107 |  		{ | 
| 108 | -			if( isset( $map[$idx][$key] ) ) { | |
| 108 | +			if (isset($map[$idx][$key])) { | |
| 109 | 109 | $idx++; | 
| 110 | 110 | } | 
| 111 | 111 | |
| 112 | - if( isset( $data[$pos] ) ) | |
| 112 | + if (isset($data[$pos])) | |
| 113 | 113 |  			{ | 
| 114 | 114 | $map[$idx][$key] = $data[$pos]; | 
| 115 | - unset( $data[$pos] ); | |
| 115 | + unset($data[$pos]); | |
| 116 | 116 | } | 
| 117 | 117 | } | 
| 118 | 118 | |
| @@ -126,39 +126,39 @@ discard block | ||
| 126 | 126 | * @param array $mappings Associative list of processor types as keys and index/data mappings as values | 
| 127 | 127 | * @return \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface Processor object | 
| 128 | 128 | */ | 
| 129 | - protected function getProcessors( array $mappings ) | |
| 129 | + protected function getProcessors(array $mappings) | |
| 130 | 130 |  	{ | 
| 131 | 131 | $context = $this->getContext(); | 
| 132 | 132 | $config = $context->getConfig(); | 
| 133 | 133 | $iface = '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\Iface'; | 
| 134 | - $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Done( $context, [] ); | |
| 134 | + $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Done($context, []); | |
| 135 | 135 | |
| 136 | - foreach( $mappings as $type => $mapping ) | |
| 136 | + foreach ($mappings as $type => $mapping) | |
| 137 | 137 |  		{ | 
| 138 | - if( ctype_alnum( $type ) === false ) | |
| 138 | + if (ctype_alnum($type) === false) | |
| 139 | 139 |  			{ | 
| 140 | 140 | $classname = is_string($type) ? '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . $type : '<not a string>'; | 
| 141 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); | |
| 141 | +				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); | |
| 142 | 142 | } | 
| 143 | 143 | |
| 144 | - $name = $config->get( 'controller/common/coupon/import/csv/processor/' . $type . '/name', 'Standard' ); | |
| 144 | +			$name = $config->get('controller/common/coupon/import/csv/processor/' . $type . '/name', 'Standard'); | |
| 145 | 145 | |
| 146 | - if( ctype_alnum( $name ) === false ) | |
| 146 | + if (ctype_alnum($name) === false) | |
| 147 | 147 |  			{ | 
| 148 | 148 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . $type . '\\' . $name : '<not a string>'; | 
| 149 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); | |
| 149 | +				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); | |
| 150 | 150 | } | 
| 151 | 151 | |
| 152 | - $classname = '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . ucfirst( $type ) . '\\' . $name; | |
| 152 | + $classname = '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . ucfirst($type) . '\\' . $name; | |
| 153 | 153 | |
| 154 | -			if( class_exists( $classname ) === false ) { | |
| 155 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); | |
| 154 | +			if (class_exists($classname) === false) { | |
| 155 | +				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname)); | |
| 156 | 156 | } | 
| 157 | 157 | |
| 158 | - $object = new $classname( $context, $mapping, $object ); | |
| 158 | + $object = new $classname($context, $mapping, $object); | |
| 159 | 159 | |
| 160 | -			if( !( $object instanceof $iface ) ) { | |
| 161 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" does not implement interface "%2$s"', $classname, $iface ) ); | |
| 160 | +			if (!($object instanceof $iface)) { | |
| 161 | +				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" does not implement interface "%2$s"', $classname, $iface)); | |
| 162 | 162 | } | 
| 163 | 163 | } | 
| 164 | 164 | |
| @@ -40,21 +40,21 @@ | ||
| 40 | 40 | * @param array $data List of CSV fields with position as key and data as value | 
| 41 | 41 | * @return array List of data which hasn't been imported | 
| 42 | 42 | */ | 
| 43 | - public function process( \Aimeos\MShop\Coupon\Item\Code\Iface $item, array $data ) | |
| 43 | + public function process(\Aimeos\MShop\Coupon\Item\Code\Iface $item, array $data) | |
| 44 | 44 |  	{ | 
| 45 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon/code' ); | |
| 46 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); | |
| 45 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon/code'); | |
| 46 | + $map = $this->getMappedChunk($data, $this->getMapping()); | |
| 47 | 47 | |
| 48 | - foreach( $map as $list ) | |
| 48 | + foreach ($map as $list) | |
| 49 | 49 |  		{ | 
| 50 | -			if( $list['coupon.code.code'] == '' ) { | |
| 50 | +			if ($list['coupon.code.code'] == '') { | |
| 51 | 51 | continue; | 
| 52 | 52 | } | 
| 53 | 53 | |
| 54 | - $item->fromArray( $list ); | |
| 55 | - $manager->saveItem( $item ); | |
| 54 | + $item->fromArray($list); | |
| 55 | + $manager->saveItem($item); | |
| 56 | 56 | } | 
| 57 | 57 | |
| 58 | - return $this->getObject()->process( $item, $data ); | |
| 58 | + return $this->getObject()->process($item, $data); | |
| 59 | 59 | } | 
| 60 | 60 | } | 
| @@ -27,8 +27,8 @@ discard block | ||
| 27 | 27 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value | 
| 28 | 28 | * @param \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object Decorated processor | 
| 29 | 29 | */ | 
| 30 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, | |
| 31 | - \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object = null ) | |
| 30 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, | |
| 31 | + \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object = null) | |
| 32 | 32 |  	{ | 
| 33 | 33 | } | 
| 34 | 34 | |
| @@ -40,7 +40,7 @@ discard block | ||
| 40 | 40 | * @param array $data List of CSV fields with position as key and data as value | 
| 41 | 41 | * @return array List of data which hasn't been imported | 
| 42 | 42 | */ | 
| 43 | - public function process( \Aimeos\MShop\Coupon\Item\Code\Iface $item, array $data ) | |
| 43 | + public function process(\Aimeos\MShop\Coupon\Item\Code\Iface $item, array $data) | |
| 44 | 44 |  	{ | 
| 45 | 45 | return $data; | 
| 46 | 46 | } | 
| @@ -26,8 +26,8 @@ discard block | ||
| 26 | 26 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value | 
| 27 | 27 | * @param \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object Decorated processor | 
| 28 | 28 | */ | 
| 29 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, | |
| 30 | - \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object = null ); | |
| 29 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, | |
| 30 | + \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object = null); | |
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | /** | 
| @@ -37,5 +37,5 @@ discard block | ||
| 37 | 37 | * @param array $data List of CSV fields with position as key and data as value | 
| 38 | 38 | * @return array List of data which hasn't been imported | 
| 39 | 39 | */ | 
| 40 | - public function process( \Aimeos\MShop\Coupon\Item\Code\Iface $item, array $data ); | |
| 40 | + public function process(\Aimeos\MShop\Coupon\Item\Code\Iface $item, array $data); | |
| 41 | 41 | } | 
| 42 | 42 | \ No newline at end of file | 
| @@ -17,16 +17,16 @@ discard block | ||
| 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 = \TestHelperCntl::getContext(); | 
| 23 | - $this->endpoint = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Done( $this->context, [] ); | |
| 23 | + $this->endpoint = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Done($this->context, []); | |
| 24 | 24 | } | 
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | protected function tearDown() | 
| 28 | 28 |  	{ | 
| 29 | - \Aimeos\MShop\Factory::setCache( false ); | |
| 29 | + \Aimeos\MShop\Factory::setCache(false); | |
| 30 | 30 | \Aimeos\MShop\Factory::clear(); | 
| 31 | 31 | } | 
| 32 | 32 | |
| @@ -47,24 +47,24 @@ discard block | ||
| 47 | 47 | 3 => '', | 
| 48 | 48 | ); | 
| 49 | 49 | |
| 50 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon' ); | |
| 51 | - $codeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon/code' ); | |
| 50 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon'); | |
| 51 | + $codeManager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon/code'); | |
| 52 | 52 | |
| 53 | - $coupon = $manager->saveItem( $manager->createItem()->setProvider( 'test' ) ); | |
| 53 | +		$coupon = $manager->saveItem($manager->createItem()->setProvider('test')); | |
| 54 | 54 | $couponCode = $codeManager->createItem(); | 
| 55 | - $couponCode->setParentId( $coupon->getId() ); | |
| 55 | + $couponCode->setParentId($coupon->getId()); | |
| 56 | 56 | |
| 57 | - $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Code\Standard( $this->context, $mapping, $this->endpoint ); | |
| 58 | - $object->process( $couponCode, $data ); | |
| 57 | + $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Code\Standard($this->context, $mapping, $this->endpoint); | |
| 58 | + $object->process($couponCode, $data); | |
| 59 | 59 | |
| 60 | - $codeManager->deleteItem( $couponCode->getId() ); | |
| 61 | - $manager->deleteItem( $coupon->getId() ); | |
| 60 | + $codeManager->deleteItem($couponCode->getId()); | |
| 61 | + $manager->deleteItem($coupon->getId()); | |
| 62 | 62 | |
| 63 | 63 | |
| 64 | - $this->assertEquals( 10, $couponCode->getCount() ); | |
| 65 | - $this->assertEquals( 'jobimporttest', $couponCode->getCode() ); | |
| 66 | - $this->assertEquals( '2000-01-01 00:00:00', $couponCode->getDateStart() ); | |
| 67 | - $this->assertEquals( null, $couponCode->getDateEnd() ); | |
| 64 | + $this->assertEquals(10, $couponCode->getCount()); | |
| 65 | +		$this->assertEquals('jobimporttest', $couponCode->getCode()); | |
| 66 | +		$this->assertEquals('2000-01-01 00:00:00', $couponCode->getDateStart()); | |
| 67 | + $this->assertEquals(null, $couponCode->getDateEnd()); | |
| 68 | 68 | } | 
| 69 | 69 | |
| 70 | 70 | |
| @@ -86,23 +86,23 @@ discard block | ||
| 86 | 86 | ); | 
| 87 | 87 | |
| 88 | 88 | |
| 89 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon' ); | |
| 90 | - $codeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon/code' ); | |
| 89 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon'); | |
| 90 | + $codeManager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon/code'); | |
| 91 | 91 | |
| 92 | - $coupon = $manager->saveItem( $manager->createItem()->setProvider( 'test' ) ); | |
| 92 | +		$coupon = $manager->saveItem($manager->createItem()->setProvider('test')); | |
| 93 | 93 | $couponCode = $codeManager->createItem(); | 
| 94 | - $couponCode->setParentId( $coupon->getId() ); | |
| 94 | + $couponCode->setParentId($coupon->getId()); | |
| 95 | 95 | |
| 96 | - $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Code\Standard( $this->context, $mapping, $this->endpoint ); | |
| 97 | - $object->process( $couponCode, $data ); | |
| 98 | - $object->process( $couponCode, $dataUpdate ); | |
| 96 | + $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Code\Standard($this->context, $mapping, $this->endpoint); | |
| 97 | + $object->process($couponCode, $data); | |
| 98 | + $object->process($couponCode, $dataUpdate); | |
| 99 | 99 | |
| 100 | - $codeManager->deleteItem( $couponCode->getId() ); | |
| 101 | - $manager->deleteItem( $coupon->getId() ); | |
| 100 | + $codeManager->deleteItem($couponCode->getId()); | |
| 101 | + $manager->deleteItem($coupon->getId()); | |
| 102 | 102 | |
| 103 | 103 | |
| 104 | - $this->assertEquals( 5, $couponCode->getCount() ); | |
| 105 | - $this->assertEquals( 'jobimporttest', $couponCode->getCode() ); | |
| 104 | + $this->assertEquals(5, $couponCode->getCount()); | |
| 105 | +		$this->assertEquals('jobimporttest', $couponCode->getCode()); | |
| 106 | 106 | } | 
| 107 | 107 | |
| 108 | 108 | |
| @@ -119,20 +119,20 @@ discard block | ||
| 119 | 119 | ); | 
| 120 | 120 | |
| 121 | 121 | |
| 122 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon' ); | |
| 123 | - $codeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon/code' ); | |
| 122 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon'); | |
| 123 | + $codeManager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon/code'); | |
| 124 | 124 | |
| 125 | - $coupon = $manager->saveItem( $manager->createItem()->setProvider( 'test' ) ); | |
| 125 | +		$coupon = $manager->saveItem($manager->createItem()->setProvider('test')); | |
| 126 | 126 | $couponCode = $codeManager->createItem(); | 
| 127 | - $couponCode->setParentId( $coupon->getId() ); | |
| 127 | + $couponCode->setParentId($coupon->getId()); | |
| 128 | 128 | |
| 129 | - $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Code\Standard( $this->context, $mapping, $this->endpoint ); | |
| 130 | - $object->process( $couponCode, $data ); | |
| 129 | + $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Code\Standard($this->context, $mapping, $this->endpoint); | |
| 130 | + $object->process($couponCode, $data); | |
| 131 | 131 | |
| 132 | - $codeManager->deleteItem( $couponCode->getId() ); | |
| 133 | - $manager->deleteItem( $coupon->getId() ); | |
| 132 | + $codeManager->deleteItem($couponCode->getId()); | |
| 133 | + $manager->deleteItem($coupon->getId()); | |
| 134 | 134 | |
| 135 | 135 | |
| 136 | - $this->assertEquals( 0, $couponCode->getCount() ); | |
| 136 | + $this->assertEquals(0, $couponCode->getCount()); | |
| 137 | 137 | } | 
| 138 | 138 | } | 
| 139 | 139 | \ No newline at end of file | 
| @@ -28,7 +28,7 @@ discard block | ||
| 28 | 28 | */ | 
| 29 | 29 | public function getName() | 
| 30 | 30 |  	{ | 
| 31 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Coupon code import CSV' ); | |
| 31 | +		return $this->getContext()->getI18n()->dt('controller/jobs', 'Coupon code import CSV'); | |
| 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', 'Imports new and updates existing coupon code from CSV files' ); | |
| 42 | +		return $this->getContext()->getI18n()->dt('controller/jobs', 'Imports new and updates existing coupon code from CSV files'); | |
| 43 | 43 | } | 
| 44 | 44 | |
| 45 | 45 | |
| @@ -71,7 +71,7 @@ discard block | ||
| 71 | 71 | * @see controller/jobs/coupon/import/csv/code/skip-lines | 
| 72 | 72 | * @see controller/jobs/coupon/import/csv/code/max-size | 
| 73 | 73 | */ | 
| 74 | - $mappings = $config->get( 'controller/jobs/coupon/import/csv/code/mapping', $mappings ); | |
| 74 | +		$mappings = $config->get('controller/jobs/coupon/import/csv/code/mapping', $mappings); | |
| 75 | 75 | |
| 76 | 76 | |
| 77 | 77 | /** controller/jobs/coupon/import/csv/code/max-size | 
| @@ -90,7 +90,7 @@ discard block | ||
| 90 | 90 | * @see controller/jobs/coupon/import/csv/code/skip-lines | 
| 91 | 91 | * @see controller/jobs/coupon/import/csv/code/mapping | 
| 92 | 92 | */ | 
| 93 | - $maxcnt = (int) $config->get( 'controller/jobs/coupon/import/csv/code/max-size', 1000 ); | |
| 93 | +		$maxcnt = (int) $config->get('controller/jobs/coupon/import/csv/code/max-size', 1000); | |
| 94 | 94 | |
| 95 | 95 | |
| 96 | 96 | /** controller/jobs/coupon/import/csv/code/skip-lines | 
| @@ -108,63 +108,63 @@ discard block | ||
| 108 | 108 | * @see controller/jobs/coupon/import/csv/code/mapping | 
| 109 | 109 | * @see controller/jobs/coupon/import/csv/code/max-size | 
| 110 | 110 | */ | 
| 111 | - $skiplines = (int) $config->get( 'controller/jobs/coupon/import/csv/code/skip-lines', 0 ); | |
| 111 | +		$skiplines = (int) $config->get('controller/jobs/coupon/import/csv/code/skip-lines', 0); | |
| 112 | 112 | |
| 113 | 113 | |
| 114 | 114 | try | 
| 115 | 115 |  		{ | 
| 116 | - $processor = $this->getProcessors( $mappings ); | |
| 117 | - $codePos = $this->getCodePosition( $mappings['code'] ); | |
| 118 | - $fs = $context->getFileSystemManager()->get( 'fs-import' ); | |
| 116 | + $processor = $this->getProcessors($mappings); | |
| 117 | + $codePos = $this->getCodePosition($mappings['code']); | |
| 118 | +			$fs = $context->getFileSystemManager()->get('fs-import'); | |
| 119 | 119 | $dir = 'couponcode/' . $context->getLocale()->getSite()->getCode(); | 
| 120 | 120 | |
| 121 | -			if( $fs->isDir( $dir ) === false ) { | |
| 121 | +			if ($fs->isDir($dir) === false) { | |
| 122 | 122 | return; | 
| 123 | 123 | } | 
| 124 | 124 | |
| 125 | - foreach( $fs->scan( $dir ) as $filename ) | |
| 125 | + foreach ($fs->scan($dir) as $filename) | |
| 126 | 126 |  			{ | 
| 127 | -				if( $filename == '.' || $filename == '..' ) { | |
| 127 | +				if ($filename == '.' || $filename == '..') { | |
| 128 | 128 | continue; | 
| 129 | 129 | } | 
| 130 | 130 | |
| 131 | - list( $couponId, $ext ) = explode( '.', $filename ); | |
| 132 | - $container = $this->getContainer( $fs->readf( $dir . '/' . $filename ) ); | |
| 131 | +				list($couponId, $ext) = explode('.', $filename); | |
| 132 | + $container = $this->getContainer($fs->readf($dir . '/' . $filename)); | |
| 133 | 133 | |
| 134 | - $msg = sprintf( 'Started coupon import from "%1$s" (%2$s)', $filename, __CLASS__ ); | |
| 135 | - $logger->log( $msg, \Aimeos\MW\Logger\Base::NOTICE ); | |
| 134 | +				$msg = sprintf('Started coupon import from "%1$s" (%2$s)', $filename, __CLASS__); | |
| 135 | + $logger->log($msg, \Aimeos\MW\Logger\Base::NOTICE); | |
| 136 | 136 | |
| 137 | - foreach( $container as $content ) | |
| 137 | + foreach ($container as $content) | |
| 138 | 138 |  				{ | 
| 139 | -					for( $i = 0; $i < $skiplines; $i++ ) { | |
| 139 | +					for ($i = 0; $i < $skiplines; $i++) { | |
| 140 | 140 | $content->next(); | 
| 141 | 141 | } | 
| 142 | 142 | |
| 143 | - while( ( $data = $this->getData( $content, $maxcnt, $codePos ) ) !== [] ) | |
| 143 | + while (($data = $this->getData($content, $maxcnt, $codePos)) !== []) | |
| 144 | 144 |  					{ | 
| 145 | - $items = $this->getCouponCodeItems( array_keys( $data ) ); | |
| 146 | - $errcnt = $this->import( $items, $data, $couponId, $processor ); | |
| 147 | - $chunkcnt = count( $data ); | |
| 145 | + $items = $this->getCouponCodeItems(array_keys($data)); | |
| 146 | + $errcnt = $this->import($items, $data, $couponId, $processor); | |
| 147 | + $chunkcnt = count($data); | |
| 148 | 148 | |
| 149 | 149 | $msg = 'Imported coupon lines from "%1$s": %2$d/%3$d (%4$s)'; | 
| 150 | - $logger->log( sprintf( $msg, $filename, $chunkcnt - $errcnt, $chunkcnt, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE ); | |
| 150 | + $logger->log(sprintf($msg, $filename, $chunkcnt - $errcnt, $chunkcnt, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE); | |
| 151 | 151 | |
| 152 | 152 | $errors += $errcnt; | 
| 153 | 153 | $total += $chunkcnt; | 
| 154 | - unset( $items, $data ); | |
| 154 | + unset($items, $data); | |
| 155 | 155 | } | 
| 156 | 156 | } | 
| 157 | 157 | |
| 158 | - $this->closeContainer( $container ); | |
| 158 | + $this->closeContainer($container); | |
| 159 | 159 | |
| 160 | 160 | $msg = 'Finished coupon import: %1$d successful, %2$s errors, %3$s total (%4$s)'; | 
| 161 | - $logger->log( sprintf( $msg, $total - $errors, $errors, $total, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE ); | |
| 161 | + $logger->log(sprintf($msg, $total - $errors, $errors, $total, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE); | |
| 162 | 162 | } | 
| 163 | 163 | } | 
| 164 | - catch( \Exception $e ) | |
| 164 | + catch (\Exception $e) | |
| 165 | 165 |  		{ | 
| 166 | - $logger->log( 'Coupon import error: ' . $e->getMessage() ); | |
| 167 | - $logger->log( $e->getTraceAsString() ); | |
| 166 | +			$logger->log('Coupon import error: ' . $e->getMessage()); | |
| 167 | + $logger->log($e->getTraceAsString()); | |
| 168 | 168 | |
| 169 | 169 | throw $e; | 
| 170 | 170 | } | 
| @@ -176,10 +176,10 @@ discard block | ||
| 176 | 176 | * | 
| 177 | 177 | * @param \Aimeos\MW\Container\Iface $container Container object | 
| 178 | 178 | */ | 
| 179 | - protected function closeContainer( \Aimeos\MW\Container\Iface $container ) | |
| 179 | + protected function closeContainer(\Aimeos\MW\Container\Iface $container) | |
| 180 | 180 |  	{ | 
| 181 | 181 | $container->close(); | 
| 182 | - unlink( $container->getName() ); | |
| 182 | + unlink($container->getName()); | |
| 183 | 183 | } | 
| 184 | 184 | |
| 185 | 185 | |
| @@ -190,16 +190,16 @@ discard block | ||
| 190 | 190 | * @return integer Position of the "coupon.code" column | 
| 191 | 191 | * @throws \Aimeos\Controller\Jobs\Exception If no mapping for "coupon.code.code" is found | 
| 192 | 192 | */ | 
| 193 | - protected function getCodePosition( array $mapping ) | |
| 193 | + protected function getCodePosition(array $mapping) | |
| 194 | 194 |  	{ | 
| 195 | - foreach( $mapping as $pos => $key ) | |
| 195 | + foreach ($mapping as $pos => $key) | |
| 196 | 196 |  		{ | 
| 197 | -			if( $key === 'coupon.code.code' ) { | |
| 197 | +			if ($key === 'coupon.code.code') { | |
| 198 | 198 | return $pos; | 
| 199 | 199 | } | 
| 200 | 200 | } | 
| 201 | 201 | |
| 202 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No "coupon.code.code" column in CSV mapping found' ) ); | |
| 202 | +		throw new \Aimeos\Controller\Jobs\Exception(sprintf('No "coupon.code.code" column in CSV mapping found')); | |
| 203 | 203 | } | 
| 204 | 204 | |
| 205 | 205 | |
| @@ -209,7 +209,7 @@ discard block | ||
| 209 | 209 | * @param string $filepath Path to the container file | 
| 210 | 210 | * @return \Aimeos\MW\Container\Iface Container object | 
| 211 | 211 | */ | 
| 212 | - protected function getContainer( $filepath ) | |
| 212 | + protected function getContainer($filepath) | |
| 213 | 213 |  	{ | 
| 214 | 214 | $config = $this->getContext()->getConfig(); | 
| 215 | 215 | |
| @@ -233,7 +233,7 @@ discard block | ||
| 233 | 233 | * @see controller/jobs/coupon/import/csv/code/container/content | 
| 234 | 234 | * @see controller/jobs/coupon/import/csv/code/container/options | 
| 235 | 235 | */ | 
| 236 | - $container = $config->get( 'controller/jobs/coupon/import/csv/code/container/type', 'File' ); | |
| 236 | +		$container = $config->get('controller/jobs/coupon/import/csv/code/container/type', 'File'); | |
| 237 | 237 | |
| 238 | 238 | /** controller/jobs/coupon/import/csv/code/container/content | 
| 239 | 239 | * Name of the content type inside the container to read the data from | 
| @@ -253,7 +253,7 @@ discard block | ||
| 253 | 253 | * @see controller/jobs/coupon/import/csv/code/container/type | 
| 254 | 254 | * @see controller/jobs/coupon/import/csv/code/container/options | 
| 255 | 255 | */ | 
| 256 | - $content = $config->get( 'controller/jobs/coupon/import/csv/code/container/content', 'CSV' ); | |
| 256 | +		$content = $config->get('controller/jobs/coupon/import/csv/code/container/content', 'CSV'); | |
| 257 | 257 | |
| 258 | 258 | /** controller/jobs/coupon/import/csv/code/container/options | 
| 259 | 259 | * List of file container options for the coupon import files | 
| @@ -270,9 +270,9 @@ discard block | ||
| 270 | 270 | * @see controller/jobs/coupon/import/csv/code/container/content | 
| 271 | 271 | * @see controller/jobs/coupon/import/csv/code/container/type | 
| 272 | 272 | */ | 
| 273 | - $options = $config->get( 'controller/jobs/coupon/import/csv/code/container/options', [] ); | |
| 273 | +		$options = $config->get('controller/jobs/coupon/import/csv/code/container/options', []); | |
| 274 | 274 | |
| 275 | - return \Aimeos\MW\Container\Factory::getContainer( $filepath, $container, $content, $options ); | |
| 275 | + return \Aimeos\MW\Container\Factory::getContainer($filepath, $container, $content, $options); | |
| 276 | 276 | } | 
| 277 | 277 | |
| 278 | 278 | |
| @@ -286,36 +286,36 @@ discard block | ||
| 286 | 286 | * @return integer Number of coupons that couldn't be imported | 
| 287 | 287 | * @throws \Aimeos\Controller\Jobs\Exception | 
| 288 | 288 | */ | 
| 289 | - protected function import( array $items, array $data, $couponId, | |
| 290 | - \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $processor ) | |
| 289 | + protected function import(array $items, array $data, $couponId, | |
| 290 | + \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $processor) | |
| 291 | 291 |  	{ | 
| 292 | 292 | $errors = 0; | 
| 293 | 293 | $context = $this->getContext(); | 
| 294 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'coupon/code' ); | |
| 294 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'coupon/code'); | |
| 295 | 295 | |
| 296 | - foreach( $data as $code => $list ) | |
| 296 | + foreach ($data as $code => $list) | |
| 297 | 297 |  		{ | 
| 298 | 298 | $manager->begin(); | 
| 299 | 299 | |
| 300 | 300 | try | 
| 301 | 301 |  			{ | 
| 302 | -				if( isset( $items[$code] ) ) { | |
| 302 | +				if (isset($items[$code])) { | |
| 303 | 303 | $item = $items[$code]; | 
| 304 | 304 |  				} else { | 
| 305 | 305 | $item = $manager->createItem(); | 
| 306 | 306 | } | 
| 307 | 307 | |
| 308 | - $item->setParentId( $couponId ); | |
| 309 | - $list = $processor->process( $item, $list ); | |
| 308 | + $item->setParentId($couponId); | |
| 309 | + $list = $processor->process($item, $list); | |
| 310 | 310 | |
| 311 | 311 | $manager->commit(); | 
| 312 | 312 | } | 
| 313 | - catch( \Exception $e ) | |
| 313 | + catch (\Exception $e) | |
| 314 | 314 |  			{ | 
| 315 | 315 | $manager->rollback(); | 
| 316 | 316 | |
| 317 | - $msg = sprintf( 'Unable to import coupon with code "%1$s": %2$s', $code, $e->getMessage() ); | |
| 318 | - $context->getLogger()->log( $msg ); | |
| 317 | +				$msg = sprintf('Unable to import coupon with code "%1$s": %2$s', $code, $e->getMessage()); | |
| 318 | + $context->getLogger()->log($msg); | |
| 319 | 319 | |
| 320 | 320 | $errors++; | 
| 321 | 321 | } | 
| @@ -160,8 +160,7 @@ discard block | ||
| 160 | 160 | $msg = 'Finished coupon import: %1$d successful, %2$s errors, %3$s total (%4$s)'; | 
| 161 | 161 | $logger->log( sprintf( $msg, $total - $errors, $errors, $total, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE ); | 
| 162 | 162 | } | 
| 163 | - } | |
| 164 | - catch( \Exception $e ) | |
| 163 | + } catch( \Exception $e ) | |
| 165 | 164 |  		{ | 
| 166 | 165 | $logger->log( 'Coupon import error: ' . $e->getMessage() ); | 
| 167 | 166 | $logger->log( $e->getTraceAsString() ); | 
| @@ -309,8 +308,7 @@ discard block | ||
| 309 | 308 | $list = $processor->process( $item, $list ); | 
| 310 | 309 | |
| 311 | 310 | $manager->commit(); | 
| 312 | - } | |
| 313 | - catch( \Exception $e ) | |
| 311 | + } catch( \Exception $e ) | |
| 314 | 312 |  			{ | 
| 315 | 313 | $manager->rollback(); | 
| 316 | 314 | |
| @@ -29,7 +29,7 @@ discard block | ||
| 29 | 29 | * @param string|null $name Name of the controller or "Standard" if null | 
| 30 | 30 | * @return \Aimeos\Controller\Jobs\Iface New controller object | 
| 31 | 31 | */ | 
| 32 | - public static function createController( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null ) | |
| 32 | + public static function createController(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null) | |
| 33 | 33 |  	{ | 
| 34 | 34 | /** controller/jobs/coupon/import/csv/code/name | 
| 35 | 35 | * Class name of the used coupon code import job controller implementation | 
| @@ -64,20 +64,20 @@ discard block | ||
| 64 | 64 | * @since 2017.10 | 
| 65 | 65 | * @category Developer | 
| 66 | 66 | */ | 
| 67 | -		if ( $name === null ) { | |
| 67 | +		if ($name === null) { | |
| 68 | 68 |  			$name = $context->getConfig()->get('controller/jobs/coupon/import/csv/code/name', 'Standard'); | 
| 69 | 69 | } | 
| 70 | 70 | |
| 71 | - if ( ctype_alnum($name) === false ) | |
| 71 | + if (ctype_alnum($name) === false) | |
| 72 | 72 |  		{ | 
| 73 | 73 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Jobs\\Coupon\\Import\\Csv\\Code\\' . $name : '<not a string>'; | 
| 74 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); | |
| 74 | +			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); | |
| 75 | 75 | } | 
| 76 | 76 | |
| 77 | 77 | $iface = '\\Aimeos\\Controller\\Jobs\\Iface'; | 
| 78 | 78 | $classname = '\\Aimeos\\Controller\\Jobs\\Coupon\\Import\\Csv\\Code\\' . $name; | 
| 79 | 79 | |
| 80 | - $controller = self::createControllerBase( $context, $aimeos, $classname, $iface ); | |
| 80 | + $controller = self::createControllerBase($context, $aimeos, $classname, $iface); | |
| 81 | 81 | |
| 82 | 82 | /** controller/jobs/coupon/import/csv/code/decorators/excludes | 
| 83 | 83 | * Excludes decorators added by the "common" option from the coupon code import CSV job controller | 
| @@ -154,6 +154,6 @@ discard block | ||
| 154 | 154 | * @see controller/jobs/coupon/import/csv/code/decorators/excludes | 
| 155 | 155 | * @see controller/jobs/coupon/import/csv/code/decorators/global | 
| 156 | 156 | */ | 
| 157 | - return self::addControllerDecorators( $context, $aimeos, $controller, 'coupon/import/csv/code' ); | |
| 157 | + return self::addControllerDecorators($context, $aimeos, $controller, 'coupon/import/csv/code'); | |
| 158 | 158 | } | 
| 159 | 159 | } | 
| 160 | 160 | \ No newline at end of file | 
| @@ -18,119 +18,119 @@ discard block | ||
| 18 | 18 | |
| 19 | 19 | protected function setUp() | 
| 20 | 20 |  	{ | 
| 21 | - \Aimeos\MShop\Factory::setCache( true ); | |
| 21 | + \Aimeos\MShop\Factory::setCache(true); | |
| 22 | 22 | |
| 23 | 23 | $this->context = \TestHelperJobs::getContext(); | 
| 24 | 24 | $this->aimeos = \TestHelperJobs::getAimeos(); | 
| 25 | 25 | $config = $this->context->getConfig(); | 
| 26 | 26 | |
| 27 | - $config->set( 'controller/jobs/product/import/csv/skip-lines', 1 ); | |
| 28 | - $config->set( 'controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/valid' ); | |
| 27 | +		$config->set('controller/jobs/product/import/csv/skip-lines', 1); | |
| 28 | +		$config->set('controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/valid'); | |
| 29 | 29 | |
| 30 | - $this->object = new \Aimeos\Controller\Jobs\Product\Import\Csv\Standard( $this->context, $this->aimeos ); | |
| 30 | + $this->object = new \Aimeos\Controller\Jobs\Product\Import\Csv\Standard($this->context, $this->aimeos); | |
| 31 | 31 | } | 
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | protected function tearDown() | 
| 35 | 35 |  	{ | 
| 36 | - \Aimeos\MShop\Factory::setCache( false ); | |
| 36 | + \Aimeos\MShop\Factory::setCache(false); | |
| 37 | 37 | \Aimeos\MShop\Factory::clear(); | 
| 38 | 38 | |
| 39 | 39 | $this->object = null; | 
| 40 | 40 | |
| 41 | -		if( file_exists( 'tmp/import.zip' ) ) { | |
| 42 | - unlink( 'tmp/import.zip' ); | |
| 41 | +		if (file_exists('tmp/import.zip')) { | |
| 42 | +			unlink('tmp/import.zip'); | |
| 43 | 43 | } | 
| 44 | 44 | } | 
| 45 | 45 | |
| 46 | 46 | |
| 47 | 47 | public function testGetName() | 
| 48 | 48 |  	{ | 
| 49 | - $this->assertEquals( 'Product import CSV', $this->object->getName() ); | |
| 49 | +		$this->assertEquals('Product import CSV', $this->object->getName()); | |
| 50 | 50 | } | 
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | public function testGetDescription() | 
| 54 | 54 |  	{ | 
| 55 | 55 | $text = 'Imports new and updates existing products from CSV files'; | 
| 56 | - $this->assertEquals( $text, $this->object->getDescription() ); | |
| 56 | + $this->assertEquals($text, $this->object->getDescription()); | |
| 57 | 57 | } | 
| 58 | 58 | |
| 59 | 59 | |
| 60 | 60 | public function testRun() | 
| 61 | 61 |  	{ | 
| 62 | - $prodcodes = array( 'job_csv_test', 'job_csv_test2' ); | |
| 63 | - $nondelete = array( 'attribute', 'product' ); | |
| 64 | - $delete = array( 'media', 'price', 'text' ); | |
| 62 | +		$prodcodes = array('job_csv_test', 'job_csv_test2'); | |
| 63 | +		$nondelete = array('attribute', 'product'); | |
| 64 | +		$delete = array('media', 'price', 'text'); | |
| 65 | 65 | |
| 66 | 66 | $convert = array( | 
| 67 | 67 | 1 => 'Text/LatinUTF8', | 
| 68 | 68 | ); | 
| 69 | 69 | |
| 70 | - $this->context->getConfig()->set( 'controller/jobs/product/import/csv/converter', $convert ); | |
| 70 | +		$this->context->getConfig()->set('controller/jobs/product/import/csv/converter', $convert); | |
| 71 | 71 | |
| 72 | 72 | $this->object->run(); | 
| 73 | 73 | |
| 74 | - $result = $this->get( $prodcodes, array_merge( $delete, $nondelete ) ); | |
| 75 | - $properties = $this->getProperties( array_keys( $result ) ); | |
| 76 | - $this->delete( $prodcodes, $delete, $nondelete ); | |
| 74 | + $result = $this->get($prodcodes, array_merge($delete, $nondelete)); | |
| 75 | + $properties = $this->getProperties(array_keys($result)); | |
| 76 | + $this->delete($prodcodes, $delete, $nondelete); | |
| 77 | 77 | |
| 78 | - $this->assertEquals( 2, count( $result ) ); | |
| 79 | - $this->assertEquals( 2, count( $properties ) ); | |
| 78 | + $this->assertEquals(2, count($result)); | |
| 79 | + $this->assertEquals(2, count($properties)); | |
| 80 | 80 | |
| 81 | -		foreach( $result as $product ) { | |
| 82 | - $this->assertEquals( 5, count( $product->getListItems() ) ); | |
| 81 | +		foreach ($result as $product) { | |
| 82 | + $this->assertEquals(5, count($product->getListItems())); | |
| 83 | 83 | } | 
| 84 | 84 | } | 
| 85 | 85 | |
| 86 | 86 | |
| 87 | 87 | public function testRunUpdate() | 
| 88 | 88 |  	{ | 
| 89 | - $prodcodes = array( 'job_csv_test', 'job_csv_test2' ); | |
| 90 | - $nondelete = array( 'attribute', 'product' ); | |
| 91 | - $delete = array( 'media', 'price', 'text' ); | |
| 89 | +		$prodcodes = array('job_csv_test', 'job_csv_test2'); | |
| 90 | +		$nondelete = array('attribute', 'product'); | |
| 91 | +		$delete = array('media', 'price', 'text'); | |
| 92 | 92 | |
| 93 | 93 | $this->object->run(); | 
| 94 | 94 | $this->object->run(); | 
| 95 | 95 | |
| 96 | - $result = $this->get( $prodcodes, array_merge( $delete, $nondelete ) ); | |
| 97 | - $properties = $this->getProperties( array_keys( $result ) ); | |
| 98 | - $this->delete( $prodcodes, $delete, $nondelete ); | |
| 96 | + $result = $this->get($prodcodes, array_merge($delete, $nondelete)); | |
| 97 | + $properties = $this->getProperties(array_keys($result)); | |
| 98 | + $this->delete($prodcodes, $delete, $nondelete); | |
| 99 | 99 | |
| 100 | - $this->assertEquals( 2, count( $result ) ); | |
| 101 | - $this->assertEquals( 2, count( $properties ) ); | |
| 100 | + $this->assertEquals(2, count($result)); | |
| 101 | + $this->assertEquals(2, count($properties)); | |
| 102 | 102 | |
| 103 | -		foreach( $result as $product ) { | |
| 104 | - $this->assertEquals( 5, count( $product->getListItems() ) ); | |
| 103 | +		foreach ($result as $product) { | |
| 104 | + $this->assertEquals(5, count($product->getListItems())); | |
| 105 | 105 | } | 
| 106 | 106 | } | 
| 107 | 107 | |
| 108 | 108 | |
| 109 | 109 | public function testRunPosition() | 
| 110 | 110 |  	{ | 
| 111 | - $prodcodes = array( 'job_csv_test', 'job_csv_test2' ); | |
| 112 | - $nondelete = array( 'attribute', 'product' ); | |
| 113 | - $delete = array( 'media', 'price', 'text' ); | |
| 111 | +		$prodcodes = array('job_csv_test', 'job_csv_test2'); | |
| 112 | +		$nondelete = array('attribute', 'product'); | |
| 113 | +		$delete = array('media', 'price', 'text'); | |
| 114 | 114 | |
| 115 | 115 | $config = $this->context->getConfig(); | 
| 116 | - $mapping = $config->set( 'controller/jobs/product/import/csv/mapping', [] ); | |
| 117 | - $mapping['item'] = array( 0 => 'product.label', 1 => 'product.code' ); | |
| 116 | +		$mapping = $config->set('controller/jobs/product/import/csv/mapping', []); | |
| 117 | + $mapping['item'] = array(0 => 'product.label', 1 => 'product.code'); | |
| 118 | 118 | |
| 119 | - $config->set( 'controller/jobs/product/import/csv/mapping', $mapping ); | |
| 120 | - $config->set( 'controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/position' ); | |
| 119 | +		$config->set('controller/jobs/product/import/csv/mapping', $mapping); | |
| 120 | +		$config->set('controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/position'); | |
| 121 | 121 | |
| 122 | 122 | $this->object->run(); | 
| 123 | 123 | |
| 124 | - $result = $this->get( $prodcodes, array_merge( $delete, $nondelete ) ); | |
| 125 | - $this->delete( $prodcodes, $delete, $nondelete ); | |
| 124 | + $result = $this->get($prodcodes, array_merge($delete, $nondelete)); | |
| 125 | + $this->delete($prodcodes, $delete, $nondelete); | |
| 126 | 126 | |
| 127 | - $this->assertEquals( 2, count( $result ) ); | |
| 127 | + $this->assertEquals(2, count($result)); | |
| 128 | 128 | } | 
| 129 | 129 | |
| 130 | 130 | |
| 131 | 131 | public function testRunProcessorInvalidPosition() | 
| 132 | 132 |  	{ | 
| 133 | - $prodcodes = array( 'job_csv_test', 'job_csv_test2' ); | |
| 133 | +		$prodcodes = array('job_csv_test', 'job_csv_test2'); | |
| 134 | 134 | |
| 135 | 135 | $mapping = array( | 
| 136 | 136 | 'item' => array( | 
| @@ -150,11 +150,11 @@ discard block | ||
| 150 | 150 | ), | 
| 151 | 151 | ); | 
| 152 | 152 | |
| 153 | - $this->context->getConfig()->set( 'controller/jobs/product/import/csv/mapping', $mapping ); | |
| 153 | +		$this->context->getConfig()->set('controller/jobs/product/import/csv/mapping', $mapping); | |
| 154 | 154 | |
| 155 | 155 | $this->object->run(); | 
| 156 | 156 | |
| 157 | - $this->delete( $prodcodes, array( 'text', 'media' ), [] ); | |
| 157 | +		$this->delete($prodcodes, array('text', 'media'), []); | |
| 158 | 158 | } | 
| 159 | 159 | |
| 160 | 160 | |
| @@ -166,9 +166,9 @@ discard block | ||
| 166 | 166 | ), | 
| 167 | 167 | ); | 
| 168 | 168 | |
| 169 | - $this->context->getConfig()->set( 'controller/jobs/product/import/csv/mapping', $mapping ); | |
| 169 | +		$this->context->getConfig()->set('controller/jobs/product/import/csv/mapping', $mapping); | |
| 170 | 170 | |
| 171 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); | |
| 171 | +		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); | |
| 172 | 172 | $this->object->run(); | 
| 173 | 173 | } | 
| 174 | 174 | |
| @@ -208,15 +208,15 @@ discard block | ||
| 208 | 208 | ), | 
| 209 | 209 | ); | 
| 210 | 210 | |
| 211 | - $this->context->getConfig()->set( 'controller/jobs/product/import/csv/mapping', $mapping ); | |
| 211 | +		$this->context->getConfig()->set('controller/jobs/product/import/csv/mapping', $mapping); | |
| 212 | 212 | |
| 213 | 213 | $config = $this->context->getConfig(); | 
| 214 | - $config->set( 'controller/jobs/product/import/csv/skip-lines', 0 ); | |
| 215 | - $config->set( 'controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/invalid' ); | |
| 214 | +		$config->set('controller/jobs/product/import/csv/skip-lines', 0); | |
| 215 | +		$config->set('controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/invalid'); | |
| 216 | 216 | |
| 217 | - $this->object = new \Aimeos\Controller\Jobs\Product\Import\Csv\Standard( $this->context, $this->aimeos ); | |
| 217 | + $this->object = new \Aimeos\Controller\Jobs\Product\Import\Csv\Standard($this->context, $this->aimeos); | |
| 218 | 218 | |
| 219 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); | |
| 219 | +		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); | |
| 220 | 220 | $this->object->run(); | 
| 221 | 221 | } | 
| 222 | 222 | |
| @@ -224,104 +224,104 @@ discard block | ||
| 224 | 224 | public function testRunBackup() | 
| 225 | 225 |  	{ | 
| 226 | 226 | $config = $this->context->getConfig(); | 
| 227 | - $config->set( 'controller/jobs/product/import/csv/container/type', 'Zip' ); | |
| 228 | - $config->set( 'controller/jobs/product/import/csv/location', 'tmp/import.zip' ); | |
| 229 | - $config->set( 'controller/jobs/product/import/csv/backup', 'tmp/test-%Y-%m-%d.zip' ); | |
| 227 | +		$config->set('controller/jobs/product/import/csv/container/type', 'Zip'); | |
| 228 | +		$config->set('controller/jobs/product/import/csv/location', 'tmp/import.zip'); | |
| 229 | +		$config->set('controller/jobs/product/import/csv/backup', 'tmp/test-%Y-%m-%d.zip'); | |
| 230 | 230 | |
| 231 | -		if( copy( __DIR__ . '/_testfiles/import.zip', 'tmp/import.zip' ) === false ) { | |
| 232 | - throw new \RuntimeException( 'Unable to copy test file' ); | |
| 231 | +		if (copy(__DIR__ . '/_testfiles/import.zip', 'tmp/import.zip') === false) { | |
| 232 | +			throw new \RuntimeException('Unable to copy test file'); | |
| 233 | 233 | } | 
| 234 | 234 | |
| 235 | 235 | $this->object->run(); | 
| 236 | 236 | |
| 237 | - $filename = strftime( 'tmp/test-%Y-%m-%d.zip' ); | |
| 238 | - $this->assertTrue( file_exists( $filename ) ); | |
| 237 | +		$filename = strftime('tmp/test-%Y-%m-%d.zip'); | |
| 238 | + $this->assertTrue(file_exists($filename)); | |
| 239 | 239 | |
| 240 | - unlink( $filename ); | |
| 240 | + unlink($filename); | |
| 241 | 241 | } | 
| 242 | 242 | |
| 243 | 243 | |
| 244 | 244 | public function testRunBackupInvalid() | 
| 245 | 245 |  	{ | 
| 246 | 246 | $config = $this->context->getConfig(); | 
| 247 | - $config->set( 'controller/jobs/product/import/csv/container/type', 'Zip' ); | |
| 248 | - $config->set( 'controller/jobs/product/import/csv/location', 'tmp/import.zip' ); | |
| 249 | - $config->set( 'controller/jobs/product/import/csv/backup', 'tmp/notexist/import.zip' ); | |
| 247 | +		$config->set('controller/jobs/product/import/csv/container/type', 'Zip'); | |
| 248 | +		$config->set('controller/jobs/product/import/csv/location', 'tmp/import.zip'); | |
| 249 | +		$config->set('controller/jobs/product/import/csv/backup', 'tmp/notexist/import.zip'); | |
| 250 | 250 | |
| 251 | -		if( copy( __DIR__ . '/_testfiles/import.zip', 'tmp/import.zip' ) === false ) { | |
| 252 | - throw new \RuntimeException( 'Unable to copy test file' ); | |
| 251 | +		if (copy(__DIR__ . '/_testfiles/import.zip', 'tmp/import.zip') === false) { | |
| 252 | +			throw new \RuntimeException('Unable to copy test file'); | |
| 253 | 253 | } | 
| 254 | 254 | |
| 255 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); | |
| 255 | +		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); | |
| 256 | 256 | $this->object->run(); | 
| 257 | 257 | } | 
| 258 | 258 | |
| 259 | 259 | |
| 260 | - protected function delete( array $prodcodes, array $delete, array $nondelete ) | |
| 260 | + protected function delete(array $prodcodes, array $delete, array $nondelete) | |
| 261 | 261 |  	{ | 
| 262 | - $catListManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( $this->context )->getSubmanager( 'lists' ); | |
| 263 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); | |
| 264 | - $listManager = $productManager->getSubManager( 'lists' ); | |
| 262 | +		$catListManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager($this->context)->getSubmanager('lists'); | |
| 263 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); | |
| 264 | +		$listManager = $productManager->getSubManager('lists'); | |
| 265 | 265 | |
| 266 | - foreach( $this->get( $prodcodes, $delete + $nondelete ) as $id => $product ) | |
| 266 | + foreach ($this->get($prodcodes, $delete + $nondelete) as $id => $product) | |
| 267 | 267 |  		{ | 
| 268 | - foreach( $delete as $domain ) | |
| 268 | + foreach ($delete as $domain) | |
| 269 | 269 |  			{ | 
| 270 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, $domain ); | |
| 270 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, $domain); | |
| 271 | 271 | |
| 272 | - foreach( $product->getListItems( $domain ) as $listItem ) | |
| 272 | + foreach ($product->getListItems($domain) as $listItem) | |
| 273 | 273 |  				{ | 
| 274 | - $manager->deleteItem( $listItem->getRefItem()->getId() ); | |
| 275 | - $listManager->deleteItem( $listItem->getId() ); | |
| 274 | + $manager->deleteItem($listItem->getRefItem()->getId()); | |
| 275 | + $listManager->deleteItem($listItem->getId()); | |
| 276 | 276 | } | 
| 277 | 277 | } | 
| 278 | 278 | |
| 279 | - foreach( $nondelete as $domain ) | |
| 279 | + foreach ($nondelete as $domain) | |
| 280 | 280 |  			{ | 
| 281 | - $ids = array_keys( $product->getListItems( $domain ) ); | |
| 282 | - $listManager->deleteItems( $ids ); | |
| 281 | + $ids = array_keys($product->getListItems($domain)); | |
| 282 | + $listManager->deleteItems($ids); | |
| 283 | 283 | } | 
| 284 | 284 | |
| 285 | - $productManager->deleteItem( $product->getId() ); | |
| 285 | + $productManager->deleteItem($product->getId()); | |
| 286 | 286 | |
| 287 | 287 | $search = $catListManager->createSearch(); | 
| 288 | - $search->setConditions( $search->compare( '==', 'catalog.lists.refid', $id ) ); | |
| 289 | - $result = $catListManager->searchItems( $search ); | |
| 288 | +			$search->setConditions($search->compare('==', 'catalog.lists.refid', $id)); | |
| 289 | + $result = $catListManager->searchItems($search); | |
| 290 | 290 | |
| 291 | - $catListManager->deleteItems( array_keys( $result ) ); | |
| 291 | + $catListManager->deleteItems(array_keys($result)); | |
| 292 | 292 | } | 
| 293 | 293 | |
| 294 | 294 | |
| 295 | - $attrManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager( $this->context ); | |
| 295 | + $attrManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager($this->context); | |
| 296 | 296 | |
| 297 | 297 | $search = $attrManager->createSearch(); | 
| 298 | - $search->setConditions( $search->compare( '==', 'attribute.code', 'import-test' ) ); | |
| 298 | +		$search->setConditions($search->compare('==', 'attribute.code', 'import-test')); | |
| 299 | 299 | |
| 300 | - $result = $attrManager->searchItems( $search ); | |
| 300 | + $result = $attrManager->searchItems($search); | |
| 301 | 301 | |
| 302 | - $attrManager->deleteItems( array_keys( $result ) ); | |
| 302 | + $attrManager->deleteItems(array_keys($result)); | |
| 303 | 303 | } | 
| 304 | 304 | |
| 305 | 305 | |
| 306 | - protected function get( array $prodcodes, array $domains ) | |
| 306 | + protected function get(array $prodcodes, array $domains) | |
| 307 | 307 |  	{ | 
| 308 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); | |
| 308 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); | |
| 309 | 309 | |
| 310 | 310 | $search = $productManager->createSearch(); | 
| 311 | - $search->setConditions( $search->compare( '==', 'product.code', $prodcodes ) ); | |
| 311 | +		$search->setConditions($search->compare('==', 'product.code', $prodcodes)); | |
| 312 | 312 | |
| 313 | - return $productManager->searchItems( $search, $domains ); | |
| 313 | + return $productManager->searchItems($search, $domains); | |
| 314 | 314 | } | 
| 315 | 315 | |
| 316 | 316 | |
| 317 | - protected function getProperties( array $prodids ) | |
| 317 | + protected function getProperties(array $prodids) | |
| 318 | 318 |  	{ | 
| 319 | - $manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context )->getSubManager( 'property' ); | |
| 319 | +		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context)->getSubManager('property'); | |
| 320 | 320 | |
| 321 | 321 | $search = $manager->createSearch(); | 
| 322 | - $search->setConditions( $search->compare( '==', 'product.property.parentid', $prodids ) ); | |
| 323 | - $search->setSortations( array( $search->sort( '+', 'product.property.type.code' ) ) ); | |
| 322 | +		$search->setConditions($search->compare('==', 'product.property.parentid', $prodids)); | |
| 323 | +		$search->setSortations(array($search->sort('+', 'product.property.type.code'))); | |
| 324 | 324 | |
| 325 | - return $manager->searchItems( $search ); | |
| 325 | + return $manager->searchItems($search); | |
| 326 | 326 | } | 
| 327 | 327 | } | 
| 328 | 328 | \ No newline at end of file |