Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/magento/framework/Test/Unit/Validator/HTML/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/old/vendor/magento/framework/Test/Unit/Validator/HTML/StyleAttributeValidatorTest.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

declare(strict_types=1);

namespace Magento\Framework\Test\Unit\Validator\HTML;

use Magento\Framework\Validation\ValidationException;
use Magento\Framework\Validator\HTML\StyleAttributeValidator;
use PHPUnit\Framework\TestCase;

class StyleAttributeValidatorTest extends TestCase
{
    /**
     * Cases for "validate" test.
     *
     * @return array
     */
    public function getAttributes(): array
    {
        return [
            'not a style' => ['class', 'value', true],
            'valid style' => ['style', 'color: blue', true],
            'invalid position style' => ['style', 'color: blue; position: absolute; width: 100%', false],
            'another invalid position style' => ['style', 'position: fixed; width: 100%', false],
            'valid position style' => ['style', 'color: blue; position: inherit; width: 100%', true],
            'valid background style' => ['style', 'color: blue; background-position: left; width: 100%', true],
            'invalid opacity style' => ['style', 'color: blue; width: 100%; opacity: 0.5', false],
            'invalid z-index style' => ['style', 'color: blue; width: 100%; z-index: 11', false]
        ];
    }

    /**
     * Test "validate" method.
     *
     * @param string $attr
     * @param string $value
     * @param bool $expectedValid
     * @return void
     * @dataProvider getAttributes
     */
    public function testValidate(string $attr, string $value, bool $expectedValid): void
    {
        $validator = new StyleAttributeValidator();

        try {
            $validator->validate('does not matter', $attr, $value);
            $actuallyValid = true;
        } catch (ValidationException $exception) {
            $actuallyValid = false;
        }
        $this->assertEquals($expectedValid, $actuallyValid);
    }
}

Spamworldpro Mini