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/amasty/feed/Test/Unit/Model/Export/Adapter/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/old/vendor/amasty/feed/Test/Unit/Model/Export/Adapter/CsvTest.php
<?php
/**
 * @author Amasty Team
 * @copyright Copyright (c) Amasty (https://www.amasty.com)
 * @package Product Feed for Magento 2
 */

namespace Amasty\Feed\Test\Unit\Model\Export\Adapter;

use Amasty\Feed\Model\Export\Adapter\Csv;
use Amasty\Feed\Test\Unit\Traits;
use PHPUnit_Framework_MockObject_MockObject as MockObject;

/**
 * Class CsvTest
 *
 * @see Csv
 *
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
 * phpcs:ignoreFile
 */
class CsvTest extends \PHPUnit\Framework\TestCase
{
    use Traits\ObjectManagerTrait;
    use Traits\ReflectionTrait;

    public const DATE = [
            'format' => 'date'
    ];
    public const PRICE = [
            'format' => 'price'
    ];
    public const INTEGER = [
            'format' => 'integer'
    ];

    /**
     * @covers Csv::_formatValue
     *
     * @dataProvider formatValueDataProvider
     *
     * @throws \ReflectionException
     */
    public function testFormatValue($field, $value, $expectedResult)
    {
        /** @var Csv|MockObject $model */
        $model = $this->createPartialMock(Csv::class, []);

        $this->setProperty($model, 'formatDate', "Y", Csv::class);
        $this->setProperty($model, 'formatPriceDecimals', 2, Csv::class);
        $this->setProperty($model, 'formatPriceDecimalPoint', ",", Csv::class);
        $this->setProperty($model, 'formatPriceThousandsSeparator', " ", Csv::class);
        $this->setProperty($model, 'formatPriceCurrencyShow', true, Csv::class);
        $this->setProperty($model, 'formatPriceCurrency', "$", Csv::class);

        $result = $this->invokeMethod($model, '_formatValue', [$field, $value]);
        $this->assertEquals($expectedResult, $result);
    }

    /**
     * Data provider for _formatValue test
     * @return array
     */
    public function formatValueDataProvider()
    {
        return [
            [self::PRICE, 100, '100,00 $'],
            [self::DATE, '10 September 2000', 2000],
            [self::INTEGER, 1, 1],
            ['wrongFormat', 1, 1],
        ];
    }
}

Spamworldpro Mini