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
Pull Request — master (#16)
by Scott van
20:36 queued 06:48
created

ObserverTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 17
rs 9.4286
cc 1
eloc 11
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
/**
17
 * Unit tests for @see EbayEnterprise_GiftCard_Model_Adminhtml_Observer
18
 */
19
class EbayEnterprise_GiftCard_Test_Model_Adminhtml_ObserverTest extends EbayEnterprise_Eb2cCore_Test_Base
20
{
21
    /** @var EbayEnterprise_GiftCard_Model_IContainer (mock) */
22
    protected $container;
23
    /** @var EbayEnterprise_GiftCard_Model_Giftcard (mock) */
24
    protected $giftCard;
25
    /** @var EbayEnterprise_GiftCard_Helper_Data (mock) */
26
    protected $helper;
27
    /** @var EbayEnterprise_GiftCard_Model_Adminhtml_Observer */
28
    protected $observer;
29
30
    public function setUp()
31
    {
32
        $this->container = $this->getMockForAbstractClass('EbayEnterprise_GiftCard_Model_IContainer');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getMockForAbstrac...Card_Model_IContainer') of type object<PHPUnit_Framework_MockObject_MockObject> is incompatible with the declared type object<EbayEnterprise_GiftCard_Model_IContainer> of property $container.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
33
        $this->giftCard = $this->getModelMock('ebayenterprise_giftcard/giftcard', ['setPin']);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getModelMock('eba...card', array('setPin')) of type object<EcomDev_PHPUnit_Mock_Proxy> is incompatible with the declared type object<EbayEnterprise_GiftCard_Model_Giftcard> of property $giftCard.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
34
        $this->helper = $this->getHelperMock('ebayenterprise_giftcard', ['addGiftCardToOrder']);
35
        $logContext = $this->getHelperMock('ebayenterprise_magelog/context', ['getMetaData']);
36
        $logContext->method('getMetaData')->willReturn([]);
37
38
        $this->observer = Mage::getModel(
39
            'ebayenterprise_giftcard/adminhtml_observer',
40
            [
41
                'container' => $this->container,
42
                'helper' => $this->helper,
43
                'log_context' => $logContext
44
            ]
45
        );
46
    }
47
48
    /**
49
     * When adding a gift card to the order, the card should be retrieved from
50
     * the container by card number, have the PIN set on the card and finally
51
     * be added to the order.
52
     */
53 View Code Duplication
    public function testAddGiftCard()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
54
    {
55
        $cardNumber = '1111111111111111';
56
        $pin = '1234';
57
58
        $this->container
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<EbayEnterprise_GiftCard_Model_IContainer>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
59
            ->method('getGiftCard')
60
            ->with($cardNumber)
61
            ->willReturn($this->giftCard);
62
        // Pin must be set on the gift card to be added.
63
        $this->giftCard->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<EbayEnterprise_GiftCard_Model_Giftcard>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
64
            ->method('setPin')
65
            ->with($this->identicalTo($pin))
66
            ->willReturnSelf();
67
        // Helper should be used to add the gift card to the order. Expect
68
        // it to be successful in this case.
69
        $this->helper->expects($this->once())
70
            ->method('addGiftCardToOrder')
71
            ->with($this->identicalTo($this->giftCard), $this->identicalTo($this->container))
72
            ->willReturnSelf();
73
74
        $this->assertSame(
75
            $this->observer,
76
            EcomDev_Utils_Reflection::invokeRestrictedMethod($this->observer, 'addGiftCard', [$cardNumber, $pin])
77
        );
78
    }
79
80
    /**
81
     * Failing to add a gift card to cart should fail silently.
82
     */
83 View Code Duplication
    public function testAddGiftCardException()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
84
    {
85
        $cardNumber = '1111111111111111';
86
        $pin = '1234';
87
88
        $this->container
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<EbayEnterprise_GiftCard_Model_IContainer>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
89
            ->method('getGiftCard')
90
            ->with($cardNumber)
91
            ->willReturn($this->giftCard);
92
        // Pin must be set on the gift card to be added.
93
        $this->giftCard->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<EbayEnterprise_GiftCard_Model_Giftcard>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
94
            ->method('setPin')
95
            ->with($this->identicalTo($pin))
96
            ->willReturnSelf();
97
        // When gift card cannot be added to cart, the helper will throw an
98
        // exception indicating the failure.
99
        $this->helper->expects($this->once())
100
            ->method('addGiftCardToOrder')
101
            ->with($this->identicalTo($this->giftCard), $this->identicalTo($this->container))
102
            ->willThrowException(new EbayEnterprise_GiftCard_Exception('TEST EXCEPTION: ' . __METHOD__));
103
104
        $this->assertSame(
105
            $this->observer,
106
            EcomDev_Utils_Reflection::invokeRestrictedMethod($this->observer, 'addGiftCard', [$cardNumber, $pin])
107
        );
108
    }
109
}
110