@@ -18,18 +18,18 @@ 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 | |
26 | - $this->object = new \Aimeos\Controller\Jobs\Product\Export\Standard( $this->context, $this->aimeos ); |
|
26 | + $this->object = new \Aimeos\Controller\Jobs\Product\Export\Standard($this->context, $this->aimeos); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | |
30 | 30 | protected function tearDown() |
31 | 31 | { |
32 | - \Aimeos\MShop\Factory::setCache( false ); |
|
32 | + \Aimeos\MShop\Factory::setCache(false); |
|
33 | 33 | \Aimeos\MShop\Factory::clear(); |
34 | 34 | |
35 | 35 | $this->object = null; |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | |
39 | 39 | public function testGetName() |
40 | 40 | { |
41 | - $this->assertEquals( 'Product export', $this->object->getName() ); |
|
41 | + $this->assertEquals('Product export', $this->object->getName()); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | 45 | public function testGetDescription() |
46 | 46 | { |
47 | 47 | $text = 'Exports all available products'; |
48 | - $this->assertEquals( $text, $this->object->getDescription() ); |
|
48 | + $this->assertEquals($text, $this->object->getDescription()); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -54,16 +54,16 @@ discard block |
||
54 | 54 | $this->object->run(); |
55 | 55 | |
56 | 56 | $ds = DIRECTORY_SEPARATOR; |
57 | - $this->assertFileExists( 'tmp' . $ds . 'aimeos-products-1.xml' ); |
|
58 | - $this->assertFileExists( 'tmp' . $ds . 'aimeos-products-2.xml' ); |
|
57 | + $this->assertFileExists('tmp' . $ds . 'aimeos-products-1.xml'); |
|
58 | + $this->assertFileExists('tmp' . $ds . 'aimeos-products-2.xml'); |
|
59 | 59 | |
60 | - $file1 = file_get_contents( 'tmp' . $ds . 'aimeos-products-1.xml' ); |
|
61 | - $file2 = file_get_contents( 'tmp' . $ds . 'aimeos-products-2.xml' ); |
|
60 | + $file1 = file_get_contents('tmp' . $ds . 'aimeos-products-1.xml'); |
|
61 | + $file2 = file_get_contents('tmp' . $ds . 'aimeos-products-2.xml'); |
|
62 | 62 | |
63 | - unlink( 'tmp' . $ds . 'aimeos-products-1.xml' ); |
|
64 | - unlink( 'tmp' . $ds . 'aimeos-products-2.xml' ); |
|
63 | + unlink('tmp' . $ds . 'aimeos-products-1.xml'); |
|
64 | + unlink('tmp' . $ds . 'aimeos-products-2.xml'); |
|
65 | 65 | |
66 | - $this->assertContains( 'CNE', $file1 ); |
|
67 | - $this->assertContains( 'U:BUNDLE', $file2 ); |
|
66 | + $this->assertContains('CNE', $file1); |
|
67 | + $this->assertContains('U:BUNDLE', $file2); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | \ No newline at end of file |
@@ -18,18 +18,18 @@ 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 | |
26 | - $this->object = new \Aimeos\Controller\Jobs\Product\Export\Sitemap\Standard( $this->context, $this->aimeos ); |
|
26 | + $this->object = new \Aimeos\Controller\Jobs\Product\Export\Sitemap\Standard($this->context, $this->aimeos); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | |
30 | 30 | protected function tearDown() |
31 | 31 | { |
32 | - \Aimeos\MShop\Factory::setCache( false ); |
|
32 | + \Aimeos\MShop\Factory::setCache(false); |
|
33 | 33 | \Aimeos\MShop\Factory::clear(); |
34 | 34 | |
35 | 35 | $this->object = null; |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | |
39 | 39 | public function testGetName() |
40 | 40 | { |
41 | - $this->assertEquals( 'Product site map', $this->object->getName() ); |
|
41 | + $this->assertEquals('Product site map', $this->object->getName()); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | 45 | public function testGetDescription() |
46 | 46 | { |
47 | 47 | $text = 'Creates a product site map for search engines'; |
48 | - $this->assertEquals( $text, $this->object->getDescription() ); |
|
48 | + $this->assertEquals($text, $this->object->getDescription()); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -54,22 +54,22 @@ discard block |
||
54 | 54 | $this->object->run(); |
55 | 55 | |
56 | 56 | $ds = DIRECTORY_SEPARATOR; |
57 | - $this->assertFileExists( 'tmp' . $ds . 'aimeos-sitemap-1.xml.gz' ); |
|
58 | - $this->assertFileExists( 'tmp' . $ds . 'aimeos-sitemap-2.xml.gz' ); |
|
59 | - $this->assertFileExists( 'tmp' . $ds . 'aimeos-sitemap-index.xml.gz' ); |
|
57 | + $this->assertFileExists('tmp' . $ds . 'aimeos-sitemap-1.xml.gz'); |
|
58 | + $this->assertFileExists('tmp' . $ds . 'aimeos-sitemap-2.xml.gz'); |
|
59 | + $this->assertFileExists('tmp' . $ds . 'aimeos-sitemap-index.xml.gz'); |
|
60 | 60 | |
61 | - $file1 = gzread( gzopen( 'tmp' . $ds . 'aimeos-sitemap-1.xml.gz', 'rb' ), 0x1000 ); |
|
62 | - $file2 = gzread( gzopen( 'tmp' . $ds . 'aimeos-sitemap-2.xml.gz', 'rb' ), 0x1000 ); |
|
63 | - $index = gzread( gzopen( 'tmp' . $ds . 'aimeos-sitemap-index.xml.gz', 'rb' ), 0x1000 ); |
|
61 | + $file1 = gzread(gzopen('tmp' . $ds . 'aimeos-sitemap-1.xml.gz', 'rb'), 0x1000); |
|
62 | + $file2 = gzread(gzopen('tmp' . $ds . 'aimeos-sitemap-2.xml.gz', 'rb'), 0x1000); |
|
63 | + $index = gzread(gzopen('tmp' . $ds . 'aimeos-sitemap-index.xml.gz', 'rb'), 0x1000); |
|
64 | 64 | |
65 | - unlink( 'tmp' . $ds . 'aimeos-sitemap-1.xml.gz' ); |
|
66 | - unlink( 'tmp' . $ds . 'aimeos-sitemap-2.xml.gz' ); |
|
67 | - unlink( 'tmp' . $ds . 'aimeos-sitemap-index.xml.gz' ); |
|
65 | + unlink('tmp' . $ds . 'aimeos-sitemap-1.xml.gz'); |
|
66 | + unlink('tmp' . $ds . 'aimeos-sitemap-2.xml.gz'); |
|
67 | + unlink('tmp' . $ds . 'aimeos-sitemap-index.xml.gz'); |
|
68 | 68 | |
69 | - $this->assertContains( 'Cafe_Noire_Expresso', $file1 ); |
|
70 | - $this->assertContains( 'Unittest%3A_Bundle', $file2 ); |
|
69 | + $this->assertContains('Cafe_Noire_Expresso', $file1); |
|
70 | + $this->assertContains('Unittest%3A_Bundle', $file2); |
|
71 | 71 | |
72 | - $this->assertContains( 'aimeos-sitemap-1.xml.gz', $index ); |
|
73 | - $this->assertContains( 'aimeos-sitemap-2.xml.gz', $index ); |
|
72 | + $this->assertContains('aimeos-sitemap-1.xml.gz', $index); |
|
73 | + $this->assertContains('aimeos-sitemap-2.xml.gz', $index); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | \ No newline at end of file |
@@ -19,18 +19,18 @@ discard block |
||
19 | 19 | |
20 | 20 | protected function setUp() |
21 | 21 | { |
22 | - \Aimeos\MShop\Factory::setCache( true ); |
|
22 | + \Aimeos\MShop\Factory::setCache(true); |
|
23 | 23 | |
24 | 24 | $this->context = \TestHelperJobs::getContext(); |
25 | 25 | $this->aimeos = \TestHelperJobs::getAimeos(); |
26 | 26 | |
27 | - $this->object = new \Aimeos\Controller\Jobs\Product\Bought\Standard( $this->context, $this->aimeos ); |
|
27 | + $this->object = new \Aimeos\Controller\Jobs\Product\Bought\Standard($this->context, $this->aimeos); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | |
31 | 31 | protected function tearDown() |
32 | 32 | { |
33 | - \Aimeos\MShop\Factory::setCache( false ); |
|
33 | + \Aimeos\MShop\Factory::setCache(false); |
|
34 | 34 | \Aimeos\MShop\Factory::clear(); |
35 | 35 | |
36 | 36 | $this->object = null; |
@@ -39,28 +39,28 @@ discard block |
||
39 | 39 | |
40 | 40 | public function testGetName() |
41 | 41 | { |
42 | - $this->assertEquals( 'Products bought together', $this->object->getName() ); |
|
42 | + $this->assertEquals('Products bought together', $this->object->getName()); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
46 | 46 | public function testGetDescription() |
47 | 47 | { |
48 | 48 | $text = 'Creates bought together product suggestions'; |
49 | - $this->assertEquals( $text, $this->object->getDescription() ); |
|
49 | + $this->assertEquals($text, $this->object->getDescription()); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
53 | 53 | public function testRun() |
54 | 54 | { |
55 | - $stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard' ) |
|
56 | - ->setConstructorArgs( array( $this->context ) ) |
|
57 | - ->setMethods( array( 'deleteItems', 'saveItem' ) ) |
|
55 | + $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard') |
|
56 | + ->setConstructorArgs(array($this->context)) |
|
57 | + ->setMethods(array('deleteItems', 'saveItem')) |
|
58 | 58 | ->getMock(); |
59 | 59 | |
60 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'product/lists', $stub ); |
|
60 | + \Aimeos\MShop\Factory::injectManager($this->context, 'product/lists', $stub); |
|
61 | 61 | |
62 | - $stub->expects( $this->atLeastOnce() )->method( 'deleteItems' ); |
|
63 | - $stub->expects( $this->atLeastOnce() )->method( 'saveItem' ); |
|
62 | + $stub->expects($this->atLeastOnce())->method('deleteItems'); |
|
63 | + $stub->expects($this->atLeastOnce())->method('saveItem'); |
|
64 | 64 | |
65 | 65 | $this->object->run(); |
66 | 66 | } |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | $context = \TestHelperJobs::getContext(); |
17 | 17 | $aimeos = \TestHelperJobs::getAimeos(); |
18 | 18 | |
19 | - $obj = \Aimeos\Controller\Jobs\Coupon\Import\Csv\Code\Factory::createController( $context, $aimeos ); |
|
20 | - $this->assertInstanceOf( '\\Aimeos\\Controller\\Jobs\\Iface', $obj); |
|
19 | + $obj = \Aimeos\Controller\Jobs\Coupon\Import\Csv\Code\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\Coupon\Import\Csv\Code\Factory::createController( $context, $aimeos, 'Wrong$$$Name' ); |
|
29 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
30 | + \Aimeos\Controller\Jobs\Coupon\Import\Csv\Code\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\Coupon\Import\Csv\Code\Factory::createController( $context, $aimeos, 'WrongClass' ); |
|
39 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
40 | + \Aimeos\Controller\Jobs\Coupon\Import\Csv\Code\Factory::createController($context, $aimeos, 'WrongClass'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -46,7 +46,7 @@ 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\Coupon\Import\Csv\Code\Factory::createController( $context, $aimeos, 'Factory' ); |
|
49 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
50 | + \Aimeos\Controller\Jobs\Coupon\Import\Csv\Code\Factory::createController($context, $aimeos, 'Factory'); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | \ No newline at end of file |
@@ -40,20 +40,20 @@ discard block |
||
40 | 40 | * @param \Aimeos\MShop\Order\Item\Base\Iface $order Full order with associated items |
41 | 41 | * @return array Two dimensional associative list of order data representing the lines in CSV |
42 | 42 | */ |
43 | - public function process( \Aimeos\MShop\Order\Item\Iface $invoice, \Aimeos\MShop\Order\Item\Base\Iface $order ) |
|
43 | + public function process(\Aimeos\MShop\Order\Item\Iface $invoice, \Aimeos\MShop\Order\Item\Base\Iface $order) |
|
44 | 44 | { |
45 | 45 | $result = []; |
46 | 46 | |
47 | - foreach( $order->getProducts() as $item ) |
|
47 | + foreach ($order->getProducts() as $item) |
|
48 | 48 | { |
49 | 49 | $data = []; |
50 | 50 | $list = $item->toArray(); |
51 | 51 | |
52 | - foreach( $item->getAttributes() as $attrItem ) |
|
52 | + foreach ($item->getAttributes() as $attrItem) |
|
53 | 53 | { |
54 | - foreach( $attrItem->toArray() as $key => $value ) |
|
54 | + foreach ($attrItem->toArray() as $key => $value) |
|
55 | 55 | { |
56 | - if( isset( $list[$key] ) ) { |
|
56 | + if (isset($list[$key])) { |
|
57 | 57 | $list[$key] .= "\n" . $value; |
58 | 58 | } else { |
59 | 59 | $list[$key] = $value; |
@@ -61,16 +61,16 @@ discard block |
||
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | - foreach( $this->getMapping() as $pos => $key ) |
|
64 | + foreach ($this->getMapping() as $pos => $key) |
|
65 | 65 | { |
66 | - if( array_key_exists( $key, $list ) ) { |
|
66 | + if (array_key_exists($key, $list)) { |
|
67 | 67 | $data[$pos] = $list[$key]; |
68 | 68 | } else { |
69 | 69 | $data[$pos] = ''; |
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | - ksort( $data ); |
|
73 | + ksort($data); |
|
74 | 74 | $result[] = $data; |
75 | 75 | } |
76 | 76 |
@@ -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", $data[0][14] ); |
|
64 | - $this->assertEquals( "width\nlength", $data[0][15] ); |
|
65 | - $this->assertEquals( "33\n36", $data[0][16] ); |
|
66 | - $this->assertEquals( "33\n36", $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", $data[0][14]); |
|
64 | + $this->assertEquals("width\nlength", $data[0][15]); |
|
65 | + $this->assertEquals("33\n36", $data[0][16]); |
|
66 | + $this->assertEquals("33\n36", $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 | } |
@@ -29,59 +29,59 @@ |
||
29 | 29 | ); |
30 | 30 | |
31 | 31 | |
32 | - $object = new \Aimeos\Controller\Common\Order\Export\Csv\Processor\Service\Standard( $context, $mapping ); |
|
33 | - |
|
34 | - $invoice = $this->getInvoice( $context ); |
|
35 | - $order = \Aimeos\MShop\Factory::createManager( $context, 'order/base' )->load( $invoice->getBaseId() ); |
|
36 | - |
|
37 | - $data = $object->process( $invoice, $order ); |
|
38 | - |
|
39 | - |
|
40 | - $this->assertEquals( 2, count( $data ) ); |
|
41 | - |
|
42 | - $this->assertEquals( 12, count( $data[0] ) ); |
|
43 | - $this->assertEquals( 'payment', $data[0][0] ); |
|
44 | - $this->assertEquals( 'OGONE', $data[0][1] ); |
|
45 | - $this->assertEquals( 'ogone', $data[0][2] ); |
|
46 | - $this->assertEquals( 'somewhere/thump1.jpg', $data[0][3] ); |
|
47 | - $this->assertEquals( '0.00', $data[0][4] ); |
|
48 | - $this->assertEquals( '0.00', $data[0][5] ); |
|
49 | - $this->assertEquals( '0.00', $data[0][6] ); |
|
50 | - $this->assertEquals( '0.0000', $data[0][7] ); |
|
51 | - $this->assertEquals( "payment\npayment\npayment\npayment\npayment\npayment\npayment\npayment\npayment", $data[0][8] ); |
|
52 | - $this->assertEquals( "ACOWNER\nACSTRING\nNAME\nOgone-alias-name\nOgone-alias-value\nREFID\nTXDATE\nX-ACCOUNT\nX-STATUS", $data[0][9] ); |
|
53 | - $this->assertEquals( "account owner\naccount number\npayment method\nogone alias name\nogone alias value\nreference id\ntransaction date\ntransaction account\ntransaction status", $data[0][10] ); |
|
54 | - $this->assertEquals( "test user\n9876543\nCreditCard\naliasName\naliasValue\n12345678\n2009-08-18\nKraft02\n9", $data[0][11] ); |
|
55 | - |
|
56 | - $this->assertEquals( 12, count( $data[1] ) ); |
|
57 | - $this->assertEquals( 'delivery', $data[1][0] ); |
|
58 | - $this->assertEquals( '73', $data[1][1] ); |
|
59 | - $this->assertEquals( 'solucia', $data[1][2] ); |
|
60 | - $this->assertEquals( 'somewhere/thump1.jpg', $data[1][3] ); |
|
61 | - $this->assertEquals( '0.00', $data[1][4] ); |
|
62 | - $this->assertEquals( '5.00', $data[1][5] ); |
|
63 | - $this->assertEquals( '0.00', $data[1][6] ); |
|
64 | - $this->assertEquals( '0.0000', $data[1][7] ); |
|
65 | - $this->assertEquals( '', $data[1][8] ); |
|
66 | - $this->assertEquals( '', $data[1][9] ); |
|
67 | - $this->assertEquals( '', $data[1][10] ); |
|
68 | - $this->assertEquals( '', $data[1][11] ); |
|
32 | + $object = new \Aimeos\Controller\Common\Order\Export\Csv\Processor\Service\Standard($context, $mapping); |
|
33 | + |
|
34 | + $invoice = $this->getInvoice($context); |
|
35 | + $order = \Aimeos\MShop\Factory::createManager($context, 'order/base')->load($invoice->getBaseId()); |
|
36 | + |
|
37 | + $data = $object->process($invoice, $order); |
|
38 | + |
|
39 | + |
|
40 | + $this->assertEquals(2, count($data)); |
|
41 | + |
|
42 | + $this->assertEquals(12, count($data[0])); |
|
43 | + $this->assertEquals('payment', $data[0][0]); |
|
44 | + $this->assertEquals('OGONE', $data[0][1]); |
|
45 | + $this->assertEquals('ogone', $data[0][2]); |
|
46 | + $this->assertEquals('somewhere/thump1.jpg', $data[0][3]); |
|
47 | + $this->assertEquals('0.00', $data[0][4]); |
|
48 | + $this->assertEquals('0.00', $data[0][5]); |
|
49 | + $this->assertEquals('0.00', $data[0][6]); |
|
50 | + $this->assertEquals('0.0000', $data[0][7]); |
|
51 | + $this->assertEquals("payment\npayment\npayment\npayment\npayment\npayment\npayment\npayment\npayment", $data[0][8]); |
|
52 | + $this->assertEquals("ACOWNER\nACSTRING\nNAME\nOgone-alias-name\nOgone-alias-value\nREFID\nTXDATE\nX-ACCOUNT\nX-STATUS", $data[0][9]); |
|
53 | + $this->assertEquals("account owner\naccount number\npayment method\nogone alias name\nogone alias value\nreference id\ntransaction date\ntransaction account\ntransaction status", $data[0][10]); |
|
54 | + $this->assertEquals("test user\n9876543\nCreditCard\naliasName\naliasValue\n12345678\n2009-08-18\nKraft02\n9", $data[0][11]); |
|
55 | + |
|
56 | + $this->assertEquals(12, count($data[1])); |
|
57 | + $this->assertEquals('delivery', $data[1][0]); |
|
58 | + $this->assertEquals('73', $data[1][1]); |
|
59 | + $this->assertEquals('solucia', $data[1][2]); |
|
60 | + $this->assertEquals('somewhere/thump1.jpg', $data[1][3]); |
|
61 | + $this->assertEquals('0.00', $data[1][4]); |
|
62 | + $this->assertEquals('5.00', $data[1][5]); |
|
63 | + $this->assertEquals('0.00', $data[1][6]); |
|
64 | + $this->assertEquals('0.0000', $data[1][7]); |
|
65 | + $this->assertEquals('', $data[1][8]); |
|
66 | + $this->assertEquals('', $data[1][9]); |
|
67 | + $this->assertEquals('', $data[1][10]); |
|
68 | + $this->assertEquals('', $data[1][11]); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
72 | - protected function getInvoice( $context ) |
|
72 | + protected function getInvoice($context) |
|
73 | 73 | { |
74 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'order' ); |
|
74 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'order'); |
|
75 | 75 | |
76 | 76 | $search = $manager->createSearch(); |
77 | - $search->setConditions( $search->compare( '==', 'order.datepayment', '2008-02-15 12:34:56' ) ); |
|
77 | + $search->setConditions($search->compare('==', 'order.datepayment', '2008-02-15 12:34:56')); |
|
78 | 78 | |
79 | - $items = $manager->searchItems( $search ); |
|
79 | + $items = $manager->searchItems($search); |
|
80 | 80 | |
81 | - if( ( $item = reset( $items ) ) !== false ) { |
|
81 | + if (($item = reset($items)) !== false) { |
|
82 | 82 | return $item; |
83 | 83 | } |
84 | 84 | |
85 | - throw new \Exception( 'No order item found' ); |
|
85 | + throw new \Exception('No order item found'); |
|
86 | 86 | } |
87 | 87 | } |
@@ -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(); |
@@ -40,25 +40,25 @@ discard block |
||
40 | 40 | * @param \Aimeos\MShop\Order\Item\Base\Iface $order Full order with associated items |
41 | 41 | * @return array Two dimensional associative list of order data representing the lines in CSV |
42 | 42 | */ |
43 | - public function process( \Aimeos\MShop\Order\Item\Iface $invoice, \Aimeos\MShop\Order\Item\Base\Iface $order ) |
|
43 | + public function process(\Aimeos\MShop\Order\Item\Iface $invoice, \Aimeos\MShop\Order\Item\Base\Iface $order) |
|
44 | 44 | { |
45 | 45 | $result = []; |
46 | 46 | $services = $order->getServices(); |
47 | 47 | |
48 | - krsort( $services ); |
|
48 | + krsort($services); |
|
49 | 49 | |
50 | - foreach( $services as $list ) |
|
50 | + foreach ($services as $list) |
|
51 | 51 | { |
52 | - foreach( $list as $item ) |
|
52 | + foreach ($list as $item) |
|
53 | 53 | { |
54 | 54 | $data = []; |
55 | 55 | $list = $item->toArray(); |
56 | 56 | |
57 | - foreach( $item->getAttributes() as $attrItem ) |
|
57 | + foreach ($item->getAttributes() as $attrItem) |
|
58 | 58 | { |
59 | - foreach( $attrItem->toArray() as $key => $value ) |
|
59 | + foreach ($attrItem->toArray() as $key => $value) |
|
60 | 60 | { |
61 | - if( isset( $list[$key] ) ) { |
|
61 | + if (isset($list[$key])) { |
|
62 | 62 | $list[$key] .= "\n" . $value; |
63 | 63 | } else { |
64 | 64 | $list[$key] = $value; |
@@ -66,16 +66,16 @@ discard block |
||
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | - foreach( $this->getMapping() as $pos => $key ) |
|
69 | + foreach ($this->getMapping() as $pos => $key) |
|
70 | 70 | { |
71 | - if( array_key_exists( $key, $list ) ) { |
|
71 | + if (array_key_exists($key, $list)) { |
|
72 | 72 | $data[$pos] = $list[$key]; |
73 | 73 | } else { |
74 | 74 | $data[$pos] = ''; |
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
78 | - ksort( $data ); |
|
78 | + ksort($data); |
|
79 | 79 | $result[] = $data; |
80 | 80 | } |
81 | 81 | } |