File tree Expand file tree Collapse file tree 2 files changed +69
-3
lines changed
app/code/core/Mage/Catalog/Model/Resource/Eav
tests/unit/Mage/Catalog/Model/Resource/Eav Expand file tree Collapse file tree 2 files changed +69
-3
lines changed Original file line number Diff line number Diff line change 10
10
* @category Mage
11
11
* @package Mage_Catalog
12
12
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
13
- * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org)
13
+ * @copyright Copyright (c) 2019-2025 The OpenMage Contributors (https://www.openmage.org)
14
14
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
15
*/
16
16
@@ -215,15 +215,17 @@ public function isScopeStore()
215
215
/**
216
216
* Retrieve store id
217
217
*
218
- * @return int
218
+ * @return int|null
219
219
*/
220
220
public function getStoreId ()
221
221
{
222
222
$ dataObject = $ this ->getDataObject ();
223
223
if ($ dataObject ) {
224
224
return $ dataObject ->getStoreId ();
225
225
}
226
- return (int ) $ this ->getData ('store_id ' );
226
+
227
+ $ storeId = $ this ->getDataByKey ('store_id ' );
228
+ return is_null ($ storeId ) ? null : (int ) $ storeId ;
227
229
}
228
230
229
231
/**
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /**
4
+ * OpenMage
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available at https://opensource.org/license/osl-3-0-php
9
+ *
10
+ * @category OpenMage
11
+ * @package OpenMage_Tests
12
+ * @copyright Copyright (c) 2025 The OpenMage Contributors (https://www.openmage.org)
13
+ * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+ declare (strict_types=1 );
17
+
18
+ namespace OpenMage \Tests \Unit \Mage \Catalog \Model \Resource \Eav ;
19
+
20
+ use Generator ;
21
+ use Mage ;
22
+ use Mage_Catalog_Model_Resource_Eav_Attribute ;
23
+ use PHPUnit \Framework \TestCase ;
24
+
25
+ class AttributeTest extends TestCase
26
+ {
27
+ public Mage_Catalog_Model_Resource_Eav_Attribute $ subject ;
28
+
29
+ public function setUp (): void
30
+ {
31
+ Mage::app ();
32
+ $ this ->subject = Mage::getModel ('catalog/resource_eav_attribute ' );
33
+ }
34
+
35
+ /**
36
+ * @dataProvider provideGetStoreId
37
+ * @group Mage_Catalog
38
+ * @group Mage_Catalog_Model
39
+ * @group Mage_Catalog_Model_Resource
40
+ */
41
+ public function testGetStoreId ($ expectedResult , $ withStoreId ): void
42
+ {
43
+ if ($ withStoreId ) {
44
+ $ this ->subject ->setStoreId ($ withStoreId );
45
+ }
46
+ $ this ->assertSame ($ expectedResult , $ this ->subject ->getStoreId ());
47
+ }
48
+
49
+ public function provideGetStoreId (): Generator
50
+ {
51
+ yield 'string ' => [
52
+ 1 ,
53
+ '1 ' ,
54
+ ];
55
+ yield 'int ' => [
56
+ 1 ,
57
+ 1 ,
58
+ ];
59
+ yield 'no store id ' => [
60
+ null ,
61
+ null ,
62
+ ];
63
+ }
64
+ }
You can’t perform that action at this time.
0 commit comments