/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
dev/tests/integration/testsuite/Magento/Review/Model/ResourceModel/RatingTest.php
89 строк
3 KB
Alexandra Zota
ACP2E-4019: CE copyright updates for 2.4.9-beta1
22 окт 2025, 10:44
22 окт 2025, 10:44
264bea2
Код
Авторство
О чём код?
<?php /** * Copyright 2015 Adobe * All Rights Reserved. */ namespace Magento\Review\Model\ResourceModel; /** * Class RatingTest */ class RatingTest extends \PHPUnit\Framework\TestCase { /** * @var int */ protected $id; /** * @magentoDbIsolation enabled */ protected function setUp(): void { $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->get(\Magento\Store\Model\StoreManagerInterface::class) ->getStore()->getId(); $rating = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( \Magento\Review\Model\Rating::class ); $rating->setData([ 'rating_code' => 'Test Rating', 'position' => 0, 'is_active' => true, 'entity_id' => 1 ]); $rating->setRatingCodes([$storeId => 'Test Rating']); $rating->setStores([$storeId]); $rating->save(); $this->id = $rating->getId(); } /** * @magentoDbIsolation enabled */ public function testRatingLoad() { $rating = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( \Magento\Review\Model\Rating::class ); $rating->load($this->id); $this->assertEquals('Test Rating', $rating->getRatingCode()); } /** * @magentoDbIsolation enabled */ public function testRatingEdit() { $rating = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( \Magento\Review\Model\Rating::class ); $rating->load($this->id); $this->assertEquals('Test Rating', $rating->getRatingCode()); $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->get(\Magento\Store\Model\StoreManagerInterface::class) ->getStore()->getId(); $rating->setRatingCode('Test Rating Edited'); $rating->setRatingCodes([$storeId => 'Test Rating Edited']); $rating->save(); $this->assertEquals('Test Rating Edited', $rating->getRatingCode()); $this->assertEquals([$storeId => 'Test Rating Edited'], $rating->getRatingCodes()); } /** * @magentoDbIsolation enabled */ public function testRatingSaveWithError() { $this->expectException('Exception'); $this->expectExceptionMessage('Rolled back transaction has not been completed correctly'); $rating = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( \Magento\Review\Model\Rating::class ); $rating->load($this->id); $rating->setRatingCodes([222 => 'Test Rating Edited']); $rating->save(); } }