|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (c) 2013-2014 eBay Enterprise, Inc. |
|
4
|
|
|
* |
|
5
|
|
|
* NOTICE OF LICENSE |
|
6
|
|
|
* |
|
7
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
|
8
|
|
|
* that is bundled with this package in the file LICENSE.md. |
|
9
|
|
|
* It is also available through the world-wide-web at this URL: |
|
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
|
11
|
|
|
* |
|
12
|
|
|
* @copyright Copyright (c) 2013-2014 eBay Enterprise, Inc. (http://www.ebayenterprise.com/) |
|
13
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
class EbayEnterprise_Tax_Test_Helper_Item_SelectionTest extends EcomDev_PHPUnit_Test_Case |
|
17
|
|
|
{ |
|
18
|
|
|
public function provideItems() |
|
19
|
|
|
{ |
|
20
|
|
|
$parents = []; |
|
21
|
|
|
$items = []; |
|
22
|
|
|
foreach(range(0, 1) as $i) { |
|
23
|
|
|
$productType = ($i ? |
|
24
|
|
|
Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE : |
|
25
|
|
|
Mage_Catalog_Model_Product_Type::TYPE_BUNDLE); |
|
26
|
|
|
$parent = $this->getModelMock('sales/quote_item_abstract', ['getProductType'], true); |
|
27
|
|
|
$parent |
|
28
|
|
|
->method('getProductType') |
|
29
|
|
|
->willReturn($productType); |
|
30
|
|
|
$parents[] = $parent; |
|
31
|
|
|
$item = $this->getModelMock('sales/quote_item_abstract', ['getParentItem'], true); |
|
32
|
|
|
$item |
|
33
|
|
|
->method('getParentItem') |
|
34
|
|
|
->willReturn(null); |
|
35
|
|
|
$items[] = $item; |
|
36
|
|
|
} |
|
37
|
|
|
foreach($parents as $parent) { |
|
38
|
|
|
$item = $this->getModelMock('sales/quote_item_abstract', ['getParentItem'], true); |
|
39
|
|
|
$item |
|
40
|
|
|
->method('getParentItem') |
|
41
|
|
|
->willReturn($parent); |
|
42
|
|
|
$items[] = $item; |
|
43
|
|
|
} |
|
44
|
|
|
return [[$items]]; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Test filtering child configurable items. |
|
49
|
|
|
* |
|
50
|
|
|
* @dataProvider provideItems |
|
51
|
|
|
*/ |
|
52
|
|
|
public function testSelectFrom(array $items) |
|
53
|
|
|
{ |
|
54
|
|
|
$helper = Mage::helper('ebayenterprise_tax/item_selection'); |
|
55
|
|
|
$selected = $helper->selectFrom($items); |
|
56
|
|
|
$this->assertCount(4, $items); |
|
57
|
|
|
$this->assertCount(2, $selected); |
|
58
|
|
|
$this->assertContainsOnlyInstancesOf('Mage_Sales_Model_Quote_Item_Abstract', $items); |
|
59
|
|
|
$this->assertContainsOnlyInstancesOf('Mage_Sales_Model_Quote_Item_Abstract', $selected); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|