GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( b150f4...c3368f )
by Scott van
17:16 queued 07:01
created

ObserversTest::provideShipGroupGiftingData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 11
rs 9.4286
cc 1
eloc 7
nc 1
nop 0
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_Eb2cGiftwrap_Test_Model_ObserversTest extends EbayEnterprise_Eb2cCore_Test_Base
17
{
18
    /**
19
     * Test that the method EbayEnterprise_Eb2cGiftwrap_Model_Observers::processDom will invoked
20
     * and will will run EbayEnterprise_Catalog_Model_Feed_File::process with the required
21
     * parameters
22
     */
23
    public function testProcessDom()
24
    {
25
        $doc = Mage::helper('eb2ccore')->getNewDomDocument();
26
        $doc->loadXML(
27
            '<ItemMaster>
28
                <Item operation_type="Add" gsi_client_id="MAGTNA" catalog_id="14">
29
                    <ItemId>
30
                        <ClientItemId>14-77554</ClientItemId>
31
                    </ItemId>
32
                    <BaseAttributes>
33
                        <ItemDescription>Gift Wrap 1</ItemDescription>
34
                        <ItemType>GiftWrap</ItemType>
35
                        <TaxCode>78</TaxCode>
36
                    </BaseAttributes>
37
                </Item>
38
            </ItemMaster>'
39
        );
40
41
        $feedData = array('event_type' => 'ItemMaster');
42
        $coreFeed = $this->getModelMockBuilder('ebayenterprise_catalog/feed_core')
43
            ->disableOriginalConstructor()
44
            ->setMethods(array('getFeedConfig'))
45
            ->getMock();
46
        $coreFeed->expects($this->any())
47
            ->method('getFeedConfig')
48
            ->will($this->returnValue($feedData));
49
50
        $observer = new Varien_Event_Observer(array('event' => new Varien_Event(array('doc' => $doc, 'file_detail' => array(
51
            'local_file' => 'EbayEnterprise/Product/ItemMaster/Inbound/ItemMaster_TestSubset.xml',
52
            'core_feed' => 'core feed mock',
53
            'timestamp' => '2012-07-06 10:09:05',
54
            'error_file' => '/EbayEnterprise/Eb2c/Feed/Product/ItemMaster/outbound/ItemMaster_20140107224605_12345_ABCD.xml',
55
            'core_feed' => $coreFeed
56
        )))));
57
        $cfgData = array(
58
            'allowable_event_type' => 'ItemMaster',
59
        );
60
        $config = $this->getModelMock('eb2cgiftwrap/feed_import_config', array('getImportConfigData'));
61
        $config->expects($this->any())
62
            ->method('getImportConfigData')
63
            ->will($this->returnValue($cfgData));
64
        $this->replaceByMock('model', 'eb2cgiftwrap/feed_import_config', $config);
65
66
        $items = $this->getModelMock('eb2cgiftwrap/feed_import_items', array());
67
        $this->replaceByMock('model', 'eb2cgiftwrap/feed_import_items', $items);
68
69
        $fileModelMock = $this->getModelMockBuilder('ebayenterprise_catalog/feed_file')
70
            ->disableOriginalConstructor()
71
            ->setMethods(array('process'))
72
            ->getMock();
73
        $fileModelMock->expects($this->once())
74
            ->method('process')
75
            ->with($this->identicalTo($config), $this->identicalTo($items))
76
            ->will($this->returnSelf());
77
        $this->replaceByMock('model', 'ebayenterprise_catalog/feed_file', $fileModelMock);
78
79
        $observers = Mage::getModel('eb2cgiftwrap/observers');
80
81
        $this->assertSame($observers, $observers->processDom($observer));
82
    }
83
84
    /**
85
     * Validate expected event configuration.
86
     *
87
     * @dataProvider dataProvider
88
     */
89
    public function testEventSetup($area, $eventName, $observerClassAlias, $observerMethod)
90
    {
91
        $this->_testEventConfig($area, $eventName, $observerClassAlias, $observerMethod);
92
    }
93
94
    /**
95
     * Provide address data, order data, if the address is the primary shipping
96
     * address, and the gift message id the address should have after the test.
97
     *
98
     * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use array<array|boolean|integer>[].

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
99
     */
100
    public function provideShipGroupGiftingData()
101
    {
102
        $giftMessageId = 11;
103
        return [
104
            // address data, order data, primary shipping, message id
105
            [['gift_message_id' => $giftMessageId], [], false, $giftMessageId], // non-primary shipping address, address has message, use address message
106
            [['gift_message_id' => $giftMessageId], [], true, $giftMessageId], // primary shipping address, order has no message, use address message
107
            [['gift_message_id' => $giftMessageId], ['gift_message_id' => $giftMessageId + 1], false, $giftMessageId], // non-primary shipping address, order has message, use address message
108
            [[], ['gift_message_id' => $giftMessageId], true, $giftMessageId], // primary shipping address, order has message, use order message
109
        ];
110
    }
111
112
    /**
113
     * @param array
114
     * @param array
115
     * @param bool
116
     * @param int
117
     * @dataProvider provideShipGroupGiftingData
118
     */
119
    public function testHandleEbayEnterpriseOrderCreateShipGroup($addressData, $orderData, $isPrimaryShippingAddress, $giftMessageId)
120
    {
121
        $address = $this->getModelMockBuilder('sales/order_address')
122
            ->setMethods(['isPrimaryShippingAddress'])
123
            ->setConstructorArgs([$addressData])
124
            ->getMock();
125
        $address->method('isPrimaryShippingAddress')->willReturn($isPrimaryShippingAddress);
126
127
        $order = Mage::getModel('sales/order', $orderData);
128
129
        $payload = $this->getMock('eBayEnterprise\RetailOrderManagement\Payload\Order\IShipGroup');
130
131
        $event = new Varien_Event(['address' => $address, 'order' => $order, 'ship_group_payload' => $payload]);
132
        $eventObserver = new Varien_Event_Observer(['event' => $event]);
133
134
        $orderGifting = $this->getModelMock('eb2cgiftwrap/order_create_gifting', ['injectGifting']);
135
        $orderGifting->expects($this->once())
136
            ->method('injectGifting')
137
            ->with($this->identicalTo($address))
138
            ->willReturnSelf();
139
140
        $observer = Mage::getModel('eb2cgiftwrap/observers', ['order_gifting' => $orderGifting]);
141
        $observer->handleEbayEnterpriseOrderCreateShipGroup($eventObserver);
142
143
        $this->assertSame($giftMessageId, $address->getGiftMessageId());
144
    }
145
}
146