Completed
Branch master (c3c77b)
by Aimeos
03:13
created

StandardTest::getInvoice()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 14
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017-2018
6
 */
7
8
namespace Aimeos\Controller\Common\Order\Export\Csv\Processor\Product;
9
10
11
class StandardTest extends \PHPUnit\Framework\TestCase
1 ignored issue
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
{
13
	public function testProcess()
14
	{
15
		$context = \TestHelperCntl::getContext();
16
		$mapping = array(
17
			0 => 'order.base.product.type',
18
			1 => 'order.base.product.stocktype',
19
			2 => 'order.base.product.suppliercode',
20
			3 => 'order.base.product.prodcode',
21
			4 => 'order.base.product.productid',
22
			5 => 'order.base.product.quantity',
23
			6 => 'order.base.product.name',
24
			7 => 'order.base.product.mediaurl',
25
			8 => 'order.base.product.price',
26
			9 => 'order.base.product.costs',
27
			10 => 'order.base.product.rebate',
28
			11 => 'order.base.product.taxrate',
29
			12 => 'order.base.product.status',
30
			13 => 'order.base.product.position',
31
			14 => 'order.base.product.attribute.type',
32
			15 => 'order.base.product.attribute.code',
33
			16 => 'order.base.product.attribute.name',
34
			17 => 'order.base.product.attribute.value',
35
		);
36
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::create( $context, 'order/base' )->load( $invoice->getBaseId() );
1 ignored issue
show
Bug introduced by
The method load() does not exist on Aimeos\MShop\Common\Manager\Iface. It seems like you code against a sub-type of Aimeos\MShop\Common\Manager\Iface such as Aimeos\MShop\Order\Manager\Base\Iface or Aimeos\MShop\Common\Manager\Decorator\Base or Aimeos\MShop\Service\Manager\Lists\Type\Standard or Aimeos\MShop\Price\Manager\Standard or Aimeos\MShop\Attribute\Manager\Type\Standard or Aimeos\MShop\Price\Manager\Lists\Type\Standard or Aimeos\MShop\Media\Manager\Type\Standard or Aimeos\MShop\Coupon\Manager\Code\Standard or Aimeos\MShop\Order\Manager\Base\Coupon\Standard or Aimeos\MShop\Product\Manager\Standard or Aimeos\MShop\Index\Manager\Standard or Aimeos\MShop\Index\Manager\Attribute\Standard or Aimeos\MShop\Index\Manager\Text\Standard or Aimeos\MShop\Index\Manager\Supplier\Standard or Aimeos\MShop\Index\Manager\Catalog\Standard or Aimeos\MShop\Index\Manager\Price\Standard or Aimeos\MShop\Supplier\Manager\Standard or Aimeos\MShop\Customer\Manager\Property\Standard or Aimeos\MShop\Order\Manager\Base\Service\Standard or Aimeos\MShop\Price\Manager\Lists\Standard or Aimeos\MShop\Supplier\Manager\Lists\Type\Standard or Aimeos\MShop\Order\Manag...vice\Attribute\Standard or Aimeos\MShop\Service\Manager\Lists\Standard or Aimeos\MShop\Tag\Manager\Type\Standard or Aimeos\MShop\Text\Manager\Lists\Standard or Aimeos\MShop\Price\Manager\Type\Standard or Aimeos\MShop\Locale\Manager\Currency\Standard or Aimeos\MShop\Order\Manag...duct\Attribute\Standard or Aimeos\MShop\Media\Manager\Lists\Type\Standard or Aimeos\MShop\Catalog\Manager\Lists\Standard or Aimeos\MShop\Tag\Manager\Standard or Aimeos\MShop\Coupon\Manager\Standard or Aimeos\MShop\Attribute\Manager\Standard or Aimeos\MShop\Attribute\M...\Property\Type\Standard or Aimeos\MShop\Service\Manager\Type\Standard or Aimeos\MShop\Product\Manager\Lists\Standard or Aimeos\MShop\Customer\Ma...\Property\Type\Standard or Aimeos\MShop\Order\Manager\Standard or Aimeos\MShop\Customer\Manager\Standard or Aimeos\MShop\Media\Manager\Standard or Aimeos\MShop\Customer\Manager\Lists\Type\Standard or Aimeos\MShop\Attribute\Manager\Lists\Standard or Aimeos\MShop\Product\Man...\Property\Type\Standard or Aimeos\MShop\Media\Manager\Lists\Standard or Aimeos\MShop\Plugin\Manager\Standard or Aimeos\MShop\Order\Manager\Base\Address\Standard or Aimeos\MShop\Catalog\Manager\Standard or Aimeos\MShop\Locale\Manager\Site\Standard or Aimeos\MShop\Product\Manager\Type\Standard or Aimeos\MShop\Supplier\Manager\Lists\Standard or Aimeos\MShop\Stock\Manager\Type\Standard or Aimeos\MShop\Text\Manager\Standard or Aimeos\MAdmin\Job\Manager\Standard or Aimeos\MShop\Customer\Manager\Group\Standard or Aimeos\MShop\Product\Manager\Lists\Type\Standard or Aimeos\MShop\Text\Manager\Lists\Type\Standard or Aimeos\MShop\Text\Manager\Type\Standard or Aimeos\MShop\Order\Manager\Status\Standard or Aimeos\MShop\Supplier\Manager\Address\Standard or Aimeos\MShop\Customer\Manager\Address\Standard or Aimeos\MShop\Plugin\Manager\Type\Standard or Aimeos\MShop\Stock\Manager\Standard or Aimeos\MShop\Stock\Manager\Nolimit or Aimeos\MShop\Attribute\Manager\Property\Standard or Aimeos\MShop\Subscription\Manager\Standard or Aimeos\MShop\Media\Manager\Property\Type\Standard or Aimeos\MShop\Product\Manager\Property\Standard or Aimeos\MShop\Locale\Manager\Language\Standard or Aimeos\MShop\Media\Manager\Property\Standard or Aimeos\MShop\Service\Manager\Standard or Aimeos\MShop\Attribute\Manager\Lists\Type\Standard or Aimeos\MAdmin\Log\Manager\Standard or Aimeos\MShop\Locale\Manager\Standard or Aimeos\MAdmin\Cache\Manager\Standard or Aimeos\MAdmin\Cache\Manager\None or Aimeos\MShop\Order\Manager\Base\Product\Standard or Aimeos\MShop\Customer\Manager\Lists\Standard or Aimeos\MShop\Catalog\Manager\Lists\Type\Standard. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
		$order = \Aimeos\MShop::create( $context, 'order/base' )->/** @scrutinizer ignore-call */ load( $invoice->getBaseId() );
Loading history...
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\nconfig", $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
	}
68
69
70
	protected function getInvoice( $context )
71
	{
72
		$manager = \Aimeos\MShop::create( $context, 'order' );
73
74
		$search = $manager->createSearch();
75
		$search->setConditions( $search->compare( '==', 'order.datepayment', '2008-02-15 12:34:56' ) );
76
77
		$items = $manager->searchItems( $search );
78
79
		if( ( $item = reset( $items ) ) !== false ) {
80
			return $item;
81
		}
82
83
		throw new \Exception( 'No order item found' );
84
	}
85
}
86