This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify |
||
5 | * it under the terms of the GNU Lesser General Public License as published by |
||
6 | * the Free Software Foundation, either version 3 of the License, or |
||
7 | * (at your option) any later version. |
||
8 | * |
||
9 | * PAYONE Magento 2 Connector is distributed in the hope that it will be useful, |
||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
12 | * GNU Lesser General Public License for more details. |
||
13 | * |
||
14 | * You should have received a copy of the GNU Lesser General Public License |
||
15 | * along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>. |
||
16 | * |
||
17 | * PHP version 5 |
||
18 | * |
||
19 | * @category Payone |
||
20 | * @package Payone_Magento2_Plugin |
||
21 | * @author FATCHIP GmbH <[email protected]> |
||
22 | * @copyright 2003 - 2017 Payone GmbH |
||
23 | * @license <http://www.gnu.org/licenses/> GNU Lesser General Public License |
||
24 | * @link http://www.payone.de |
||
25 | */ |
||
26 | |||
27 | namespace Payone\Core\Test\Unit\Helper; |
||
28 | |||
29 | use Payone\Core\Helper\Request; |
||
30 | use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; |
||
31 | use Magento\Store\Model\StoreManagerInterface; |
||
32 | use Magento\Store\Api\Data\StoreInterface; |
||
33 | use Magento\Framework\App\Helper\Context; |
||
34 | use Magento\Store\Model\ScopeInterface; |
||
35 | use Magento\Framework\App\Config\ScopeConfigInterface; |
||
36 | use Payone\Core\Helper\Environment; |
||
37 | use Payone\Core\Helper\Shop; |
||
38 | use Payone\Core\Model\PayoneConfig; |
||
39 | use Locale; |
||
40 | use Payone\Core\Test\Unit\BaseTestCase; |
||
41 | use Payone\Core\Model\Test\PayoneObjectManager; |
||
42 | |||
43 | class RequestTest extends BaseTestCase |
||
44 | { |
||
45 | /** |
||
46 | * @var ObjectManager|PayoneObjectManager |
||
47 | */ |
||
48 | private $objectManager; |
||
49 | |||
50 | /** |
||
51 | * @var Request |
||
52 | */ |
||
53 | private $request; |
||
54 | |||
55 | /** |
||
56 | * @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject |
||
57 | */ |
||
58 | private $scopeConfig; |
||
59 | |||
60 | /** |
||
61 | * @var string |
||
62 | */ |
||
63 | private $encoding = 'UTF-8'; |
||
64 | |||
65 | /** |
||
66 | * @var string |
||
67 | */ |
||
68 | private $version = '1.2.3'; |
||
69 | |||
70 | protected function setUp() |
||
71 | { |
||
72 | $this->objectManager = $this->getObjectManager(); |
||
73 | |||
74 | $this->scopeConfig = $this->getMockBuilder(ScopeConfigInterface::class)->disableOriginalConstructor()->getMock(); |
||
75 | $context = $this->objectManager->getObject(Context::class, ['scopeConfig' => $this->scopeConfig]); |
||
76 | |||
77 | $store = $this->getMockBuilder(StoreInterface::class)->disableOriginalConstructor()->getMock(); |
||
78 | $store->method('getCode')->willReturn(null); |
||
79 | |||
80 | $storeManager = $this->getMockBuilder(StoreManagerInterface::class)->disableOriginalConstructor()->getMock(); |
||
81 | $storeManager->method('getStore')->willReturn($store); |
||
82 | |||
83 | $environmentHelper = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock(); |
||
84 | $environmentHelper->method('getEncoding')->willReturn($this->encoding); |
||
85 | |||
86 | $shopHelper = $this->getMockBuilder(Shop::class)->disableOriginalConstructor()->getMock(); |
||
87 | $shopHelper->method('getMagentoVersion')->willReturn($this->version); |
||
88 | $shopHelper->method('getLocale')->willReturn('de'); |
||
89 | |||
90 | $this->request = $this->objectManager->getObject(Request::class, [ |
||
91 | 'context' => $context, |
||
92 | 'storeManager' => $storeManager, |
||
93 | 'environmentHelper' => $environmentHelper, |
||
94 | 'shopHelper' => $shopHelper |
||
95 | ]); |
||
96 | } |
||
97 | |||
98 | public function testGetBankaccountCheckRequest() |
||
99 | { |
||
100 | $this->scopeConfig->expects($this->any()) |
||
0 ignored issues
–
show
|
|||
101 | ->method('getValue') |
||
102 | ->willReturnMap( |
||
103 | [ |
||
104 | ['payone_payment/'.PayoneConfig::METHOD_DEBIT.'/check_bankaccount', ScopeInterface::SCOPE_STORE, null, '1'], |
||
105 | ['payone_payment/'.PayoneConfig::METHOD_DEBIT.'/mode', ScopeInterface::SCOPE_STORE, null, 'live'], |
||
106 | ['payone_general/global/mid', ScopeInterface::SCOPE_STORE, null, '12345'], |
||
107 | ['payone_general/global/aid', ScopeInterface::SCOPE_STORE, null, '54321'], |
||
108 | ['payone_general/global/portalid', ScopeInterface::SCOPE_STORE, null, '0815'], |
||
109 | ['payone_general/global/key', ScopeInterface::SCOPE_STORE, null, 'abcde'], |
||
110 | ['payone_payment/'.PayoneConfig::METHOD_DEBIT.'/bankaccountcheck_type', ScopeInterface::SCOPE_STORE, null, '1'], |
||
111 | ] |
||
112 | ); |
||
113 | |||
114 | $result = $this->request->getBankaccountCheckRequest(); |
||
115 | $expected = [ |
||
116 | 'request' => 'bankaccountcheck', |
||
117 | 'responsetype' => 'JSON', |
||
118 | 'mode' => 'live', |
||
119 | 'mid' => '12345', |
||
120 | 'aid' => '54321', |
||
121 | 'portalid' => '0815', |
||
122 | 'encoding' => $this->encoding, |
||
123 | 'language' => 'de', |
||
124 | 'checktype' => '1', |
||
125 | 'hash' => $this->request->getBankaccountCheckRequestHash(), |
||
126 | 'integrator_name' => 'Magento2', |
||
127 | 'integrator_version' => $this->version, |
||
128 | 'solution_name' => 'fatchip', |
||
129 | 'solution_version' => PayoneConfig::MODULE_VERSION, |
||
130 | ]; |
||
131 | $this->assertEquals($expected, $result); |
||
132 | } |
||
133 | |||
134 | public function testGetBankaccountCheckRequestEmpty() |
||
135 | { |
||
136 | $this->scopeConfig->expects($this->any()) |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Magento\Framework\App\Config\ScopeConfigInterface .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
137 | ->method('getValue') |
||
138 | ->willReturnMap([['payone_payment/'.PayoneConfig::METHOD_DEBIT.'/check_bankaccount', ScopeInterface::SCOPE_STORE, null, '0']]); |
||
139 | $result = $this->request->getBankaccountCheckRequest(); |
||
140 | $expected = ''; |
||
141 | $this->assertEquals($expected, $result); |
||
142 | } |
||
143 | |||
144 | public function testGetHostedIframeRequest() |
||
145 | { |
||
146 | $this->scopeConfig->expects($this->any()) |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Magento\Framework\App\Config\ScopeConfigInterface .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
147 | ->method('getValue') |
||
148 | ->willReturnMap( |
||
149 | [ |
||
150 | ['payone_payment/'.PayoneConfig::METHOD_CREDITCARD.'/mode', ScopeInterface::SCOPE_STORE, null, 'live'], |
||
151 | ['payone_general/global/mid', ScopeInterface::SCOPE_STORE, null, '12345'], |
||
152 | ['payone_general/global/aid', ScopeInterface::SCOPE_STORE, null, '54321'], |
||
153 | ['payone_general/global/portalid', ScopeInterface::SCOPE_STORE, null, '0815'], |
||
154 | ['payone_general/global/key', ScopeInterface::SCOPE_STORE, null, 'abcde'], |
||
155 | ] |
||
156 | ); |
||
157 | |||
158 | $result = $this->request->getHostedIframeRequest(); |
||
159 | $expected = [ |
||
160 | 'request' => 'creditcardcheck', |
||
161 | 'responsetype' => 'JSON', |
||
162 | 'mode' => 'live', |
||
163 | 'mid' => '12345', |
||
164 | 'aid' => '54321', |
||
165 | 'portalid' => '0815', |
||
166 | 'encoding' => $this->encoding, |
||
167 | 'storecarddata' => 'yes', |
||
168 | 'hash' => $this->request->getHostedIframeRequestCCHash() |
||
169 | ]; |
||
170 | $this->assertEquals($expected, $result); |
||
171 | } |
||
172 | } |
||
173 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: