-
-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
167 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
tests/unit/Mage/Catalog/Model/Product/Option/Type/TextTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
/** | ||
* OpenMage | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available at https://opensource.org/license/osl-3-0-php | ||
* | ||
* @category OpenMage | ||
* @package OpenMage_Tests | ||
* @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) | ||
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenMage\Tests\Unit\Mage\Catalog\Model\Product\Option\Type; | ||
|
||
use Generator; | ||
use Mage; | ||
use Mage_Catalog_Model_Product_Option; | ||
use Mage_Catalog_Model_Product_Option_Type_Text as Subject; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class TextTest extends TestCase | ||
{ | ||
public Subject $subject; | ||
|
||
public function setUp(): void | ||
{ | ||
Mage::app(); | ||
$this->subject = Mage::getModel('catalog/product_option_type_text'); | ||
} | ||
|
||
/** | ||
* @group Mage_Catalog | ||
* @group Mage_Catalog_Model | ||
* @group runInSeparateProcess | ||
* @runInSeparateProcess | ||
*/ | ||
public function testValidateUserValue(): void | ||
{ | ||
$this->subject->setOption(new Mage_Catalog_Model_Product_Option()); | ||
$this->assertInstanceOf(Subject::class, $this->subject->validateUserValue([])); | ||
} | ||
|
||
|
||
/** | ||
* @dataProvider providePrepareForCart | ||
* @group Mage_Catalog | ||
* @group Mage_Catalog_Model | ||
*/ | ||
public function testPrepareForCart($expectedResult, bool $setIsValid = true, $setUserValue = null): void | ||
{ | ||
$this->subject->setIsValid($setIsValid)->setUserValue($setUserValue); | ||
$this->assertSame($expectedResult, $this->subject->prepareForCart()); | ||
} | ||
|
||
public function providePrepareForCart(): Generator | ||
{ | ||
yield 'valid' => [ | ||
'test', | ||
true, | ||
'test', | ||
]; | ||
yield 'invalid' => [ | ||
null, | ||
]; | ||
} | ||
|
||
/** | ||
* @covers Mage_Catalog_Model_Product_Option_Type_Text::getFormattedOptionValue() | ||
* @group Mage_Catalog | ||
* @group Mage_Catalog_Model | ||
*/ | ||
public function testGetDefaultAttributeSetId(): void | ||
{ | ||
$this->assertIsString($this->subject->getFormattedOptionValue('')); | ||
} | ||
} |