@@ -18,95 +18,95 @@ |
||
| 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 ); |
|
| 27 | + $config->set('controller/jobs/product/import/csv/skip-lines', 1); |
|
| 28 | 28 | |
| 29 | - $this->object = new \Aimeos\Controller\Jobs\Coupon\Import\Csv\Code\Standard( $this->context, $this->aimeos ); |
|
| 29 | + $this->object = new \Aimeos\Controller\Jobs\Coupon\Import\Csv\Code\Standard($this->context, $this->aimeos); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | protected function tearDown() |
| 34 | 34 | { |
| 35 | - \Aimeos\MShop\Factory::setCache( false ); |
|
| 35 | + \Aimeos\MShop\Factory::setCache(false); |
|
| 36 | 36 | \Aimeos\MShop\Factory::clear(); |
| 37 | 37 | |
| 38 | - unset( $this->object ); |
|
| 38 | + unset($this->object); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | public function testGetName() |
| 43 | 43 | { |
| 44 | - $this->assertEquals( 'Coupon code import CSV', $this->object->getName() ); |
|
| 44 | + $this->assertEquals('Coupon code import CSV', $this->object->getName()); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | |
| 48 | 48 | public function testGetDescription() |
| 49 | 49 | { |
| 50 | 50 | $text = 'Imports new and updates existing coupon code from CSV files'; |
| 51 | - $this->assertEquals( $text, $this->object->getDescription() ); |
|
| 51 | + $this->assertEquals($text, $this->object->getDescription()); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | public function testRun() |
| 56 | 56 | { |
| 57 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon' ); |
|
| 58 | - $coupon = $manager->saveItem( $manager->createItem()->setProvider( 'Example' ) ); |
|
| 57 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon'); |
|
| 58 | + $coupon = $manager->saveItem($manager->createItem()->setProvider('Example')); |
|
| 59 | 59 | |
| 60 | 60 | $dir = 'tmp/import/couponcode/unittest'; |
| 61 | 61 | $filepath = $dir . '/' . $coupon->getId() . '.csv'; |
| 62 | 62 | |
| 63 | - if( !is_dir( $dir ) && mkdir( 'tmp/import/couponcode/unittest', 0775, true ) === false ) { |
|
| 64 | - throw new \Exception( sprintf( 'Unable to create directory "%1$s"', $dir ) ); |
|
| 63 | + if (!is_dir($dir) && mkdir('tmp/import/couponcode/unittest', 0775, true) === false) { |
|
| 64 | + throw new \Exception(sprintf('Unable to create directory "%1$s"', $dir)); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $content = 'code,count,start,end |
| 68 | 68 | jobccimport1,3,2000-01-01 00:00:00, |
| 69 | 69 | jobccimport2,5,,'; |
| 70 | 70 | |
| 71 | - if( file_put_contents( $filepath, $content ) === false ) { |
|
| 72 | - throw new \Exception( sprintf( 'Unable to create file "%1$s"', $file ) ); |
|
| 71 | + if (file_put_contents($filepath, $content) === false) { |
|
| 72 | + throw new \Exception(sprintf('Unable to create file "%1$s"', $file)); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $this->object->run(); |
| 76 | 76 | |
| 77 | 77 | |
| 78 | - $codeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon/code' ); |
|
| 79 | - $code1 = $codeManager->findItem( 'jobccimport1' ); |
|
| 80 | - $code2 = $codeManager->findItem( 'jobccimport2' ); |
|
| 78 | + $codeManager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon/code'); |
|
| 79 | + $code1 = $codeManager->findItem('jobccimport1'); |
|
| 80 | + $code2 = $codeManager->findItem('jobccimport2'); |
|
| 81 | 81 | |
| 82 | - $manager->deleteItem( $coupon->getId() ); |
|
| 82 | + $manager->deleteItem($coupon->getId()); |
|
| 83 | 83 | |
| 84 | - $this->assertEquals( 3, $code1->getCount() ); |
|
| 85 | - $this->assertEquals( '2000-01-01 00:00:00', $code1->getDateStart() ); |
|
| 86 | - $this->assertEquals( null, $code1->getDateEnd() ); |
|
| 84 | + $this->assertEquals(3, $code1->getCount()); |
|
| 85 | + $this->assertEquals('2000-01-01 00:00:00', $code1->getDateStart()); |
|
| 86 | + $this->assertEquals(null, $code1->getDateEnd()); |
|
| 87 | 87 | |
| 88 | - $this->assertEquals( 5, $code2->getCount() ); |
|
| 89 | - $this->assertEquals( null, $code2->getDateStart() ); |
|
| 90 | - $this->assertEquals( null, $code2->getDateEnd() ); |
|
| 88 | + $this->assertEquals(5, $code2->getCount()); |
|
| 89 | + $this->assertEquals(null, $code2->getDateStart()); |
|
| 90 | + $this->assertEquals(null, $code2->getDateEnd()); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | |
| 94 | 94 | public function testRunException() |
| 95 | 95 | { |
| 96 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon' ); |
|
| 96 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon'); |
|
| 97 | 97 | |
| 98 | 98 | $dir = 'tmp/import/couponcode/unittest'; |
| 99 | 99 | $filepath = $dir . '/0.csv'; |
| 100 | 100 | |
| 101 | - if( !is_dir( $dir ) && mkdir( 'tmp/import/couponcode/unittest', 0775, true ) === false ) { |
|
| 102 | - throw new \Exception( sprintf( 'Unable to create directory "%1$s"', $dir ) ); |
|
| 101 | + if (!is_dir($dir) && mkdir('tmp/import/couponcode/unittest', 0775, true) === false) { |
|
| 102 | + throw new \Exception(sprintf('Unable to create directory "%1$s"', $dir)); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | $content = 'code,count,start,end |
| 106 | 106 | jobccimport1,,,'; |
| 107 | 107 | |
| 108 | - if( file_put_contents( $filepath, $content ) === false ) { |
|
| 109 | - throw new \Exception( sprintf( 'Unable to create file "%1$s"', $file ) ); |
|
| 108 | + if (file_put_contents($filepath, $content) === false) { |
|
| 109 | + throw new \Exception(sprintf('Unable to create file "%1$s"', $file)); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | $this->object->run(); |