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/dev/tests/integration/testsuite/Magento/Tax/Model/Rate/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/old/dev/tests/integration/testsuite/Magento/Tax/Model/Rate/ProviderTest.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\Tax\Model\Rate;

use Magento\Tax\Model\Calculation\Rate;
use Magento\Tax\Model\Rate\Provider;
use Magento\Tax\Model\ResourceModel\Calculation\Rate\Collection;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Framework\Api\SearchCriteriaBuilder;

/**
 * Class ProviderTest provides coverage
 * of Tax Rate model options provider.
 */
class ProviderTest extends \PHPUnit\Framework\TestCase
{
    /**
     * Test of requesting tax rates by search criteria.
     */
    public function testToOptionArray()
    {
        $objectManager = Bootstrap::getObjectManager();
        $optionsCount = 1;

        /** @var Collection $collection */
        $collection = $objectManager->get(Collection::class);
        $expectedResult = [];

        /** @var $taxRate Rate */
        foreach ($collection as $taxRate) {
            $expectedResult[] = ['value' => $taxRate->getId(), 'label' => $taxRate->getCode()];
            if (count($expectedResult) >= $optionsCount) {
                break;
            }
        }

        /** @var Source $source */
        if (empty($expectedResult)) {
            $this->fail('Preconditions failed: At least one tax rate should be available.');
        }

        $provider = $objectManager->get(Provider::class);

        /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
        $searchCriteriaBuilder =  $objectManager->create(SearchCriteriaBuilder::class);
        $searchCriteriaBuilder->setPageSize($optionsCount);
        $searchCriteriaBuilder->setCurrentPage(1);

        $searchCriteria = $searchCriteriaBuilder->create();

        $this->assertEquals(
            $expectedResult,
            $provider->toOptionArray($searchCriteria),
            'Tax rate options are invalid.'
        );
    }
}

Spamworldpro Mini