|
7 | 7 |
|
8 | 8 | namespace Magento\Rss\Test\Unit\Model; |
9 | 9 |
|
| 10 | +use Magento\Catalog\Block\Rss\Product\NewProducts; |
10 | 11 | use Magento\Framework\App\CacheInterface; |
11 | 12 | use Magento\Framework\App\FeedFactoryInterface; |
12 | 13 | use Magento\Framework\App\FeedInterface; |
@@ -148,6 +149,47 @@ public function testGetFeeds(): void |
148 | 149 | $this->assertEquals($this->feedData, $this->rss->getFeeds()); |
149 | 150 | } |
150 | 151 |
|
| 152 | + /** |
| 153 | + * Get new products feed test |
| 154 | + * |
| 155 | + * @return void |
| 156 | + */ |
| 157 | + public function testGetNewProductsFeed(): void |
| 158 | + { |
| 159 | + $dataProvider = $this->createMock(NewProducts::class); |
| 160 | + $dataProvider->expects($this->atLeastOnce()) |
| 161 | + ->method('getCacheKey') |
| 162 | + ->willReturn('cache_key'); |
| 163 | + $dataProvider->expects($this->atLeastOnce()) |
| 164 | + ->method('getCacheLifetime') |
| 165 | + ->willReturn(100); |
| 166 | + $dataProvider->expects($this->once()) |
| 167 | + ->method('getRssData') |
| 168 | + ->willReturn($this->feedData); |
| 169 | + $dataProvider->expects($this->once())->method('getIdentities')->willReturn(['identity']); |
| 170 | + |
| 171 | + $this->rss->setDataProvider($dataProvider); |
| 172 | + |
| 173 | + $this->cacheMock->expects($this->once()) |
| 174 | + ->method('load') |
| 175 | + ->with('cache_key') |
| 176 | + ->willReturn(false); |
| 177 | + $this->cacheMock->expects($this->once()) |
| 178 | + ->method('save') |
| 179 | + ->with('serializedData') |
| 180 | + ->willReturn(true); |
| 181 | + $this->serializerMock->expects($this->once()) |
| 182 | + ->method('serialize') |
| 183 | + ->with($this->feedData) |
| 184 | + ->willReturn(self::STUB_SERIALIZED_DATA); |
| 185 | + $this->serializerMock->expects($this->once()) |
| 186 | + ->method('unserialize') |
| 187 | + ->with(self::STUB_SERIALIZED_DATA) |
| 188 | + ->willReturn($this->feedData); |
| 189 | + |
| 190 | + $this->assertEquals($this->feedData, $this->rss->getFeeds()); |
| 191 | + } |
| 192 | + |
151 | 193 | public function testGetFeedsWithCache() |
152 | 194 | { |
153 | 195 | $dataProvider = $this->getMockForAbstractClass(DataProviderInterface::class); |
|
0 commit comments