/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
dev/tests/integration/testsuite/Magento/Rule/Model/Condition/AbstractTest.php
59 строк
3 KB
Raj Mohan R
AC-16236::Upgrade Core Test Framework to PHPUnit 12 and Migrate from PHPUnit 10
11 фев 2026, 13:51
11 фев 2026, 13:51
152ed41
Код
Авторство
О чём код?
<?php /** * Copyright 2013 Adobe * All Rights Reserved. */ /** * Test class for \Magento\Rule\Model\Condition\AbstractCondition */ namespace Magento\Rule\Model\Condition; use Magento\Framework\TestFramework\Unit\Helper\MockCreationTrait; class AbstractTest extends \PHPUnit\Framework\TestCase { use MockCreationTrait; public function testGetValueElement() { $layoutMock = $this->createMock(\Magento\Framework\View\Layout::class); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $context = $objectManager->create(\Magento\Rule\Model\Condition\Context::class, ['layout' => $layoutMock]); /** @var \Magento\Rule\Model\Condition\AbstractCondition $model */ $model = $this->createPartialMockWithReflection( \Magento\Rule\Model\Condition\AbstractCondition::class, ['getValueElementRenderer'] ); // Set the context properties via reflection since constructor was skipped // AbstractCondition extracts these from context in its constructor $assetRepoProperty = new \ReflectionProperty(\Magento\Rule\Model\Condition\AbstractCondition::class, '_assetRepo'); $assetRepoProperty->setValue($model, $context->getAssetRepository()); $localeDateProperty = new \ReflectionProperty(\Magento\Rule\Model\Condition\AbstractCondition::class, '_localeDate'); $localeDateProperty->setValue($model, $context->getLocaleDate()); $layoutProperty = new \ReflectionProperty(\Magento\Rule\Model\Condition\AbstractCondition::class, '_layout'); $layoutProperty->setValue($model, $context->getLayout()); $editableBlock = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( \Magento\Rule\Block\Editable::class ); $model->expects($this->any())->method('getValueElementRenderer')->willReturn($editableBlock); $rule = $this->createMock(\Magento\Rule\Model\AbstractModel::class); $rule->expects($this->any()) ->method('getForm') ->willReturn( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Framework\Data\Form::class) ); $model->setRule($rule); $property = new \ReflectionProperty(\Magento\Rule\Model\Condition\AbstractCondition::class, '_inputType'); $property->setValue($model, 'date'); $element = $model->getValueElement(); $this->assertNotNull($element); $this->assertNotEmpty($element->getDateFormat()); } }