File tree Expand file tree Collapse file tree 2 files changed +51
-1
lines changed Expand file tree Collapse file tree 2 files changed +51
-1
lines changed Original file line number Diff line number Diff line change 5
5
*/
6
6
namespace Magento \Review \Model ;
7
7
8
+ use Magento \Framework \DataObject \IdentityInterface ;
9
+ use Magento \Store \Model \Store ;
10
+
8
11
/**
9
12
* Rating model
10
13
*
18
21
*
19
22
* @author Magento Core Team <core@magentocommerce.com>
20
23
*/
21
- class Rating extends \Magento \Framework \Model \AbstractModel
24
+ class Rating extends \Magento \Framework \Model \AbstractModel implements IdentityInterface
22
25
{
23
26
/**
24
27
* rating entity codes
@@ -161,4 +164,15 @@ public function getEntityIdByCode($entityCode)
161
164
{
162
165
return $ this ->getResource ()->getEntityIdByCode ($ entityCode );
163
166
}
167
+
168
+ /**
169
+ * Return unique ID(s) for each object in system
170
+ *
171
+ * @return array
172
+ */
173
+ public function getIdentities ()
174
+ {
175
+ // skip cache for all store
176
+ return [Store::CACHE_TAG ];
177
+ }
164
178
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © 2015 Magento. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ namespace Magento \Review \Model ;
7
+
8
+ use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
9
+ use Magento \Store \Model \Store ;
10
+ use Magento \Review \Model \Rating ;
11
+
12
+ class RatingTest extends \PHPUnit_Framework_TestCase
13
+ {
14
+ /**
15
+ * @var \Magento\Review\Model\Rating
16
+ */
17
+ private $ rating ;
18
+
19
+ /**
20
+ * Init objects needed by tests
21
+ */
22
+ protected function setUp ()
23
+ {
24
+ $ helper = new ObjectManager ($ this );
25
+ $ this ->rating = $ helper ->getObject (Rating::class);
26
+ }
27
+
28
+ /**
29
+ * @covers \Magento\Review\Model\Rating::getIdentities()
30
+ * @return void
31
+ */
32
+ public function testGetIdentities ()
33
+ {
34
+ static ::assertEquals ([Store::CACHE_TAG ], $ this ->rating ->getIdentities ());
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments