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/module-sales/Test/Unit/Block/Adminhtml/Order/Invoice/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/module-sales/Test/Unit/Block/Adminhtml/Order/Invoice/ViewTest.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

/**
 * Test class for \Magento\Sales\Block\Adminhtml\Order\Invoice\View
 */
namespace Magento\Sales\Test\Unit\Block\Adminhtml\Order\Invoice;

use Magento\Sales\Block\Adminhtml\Order\Invoice\View;
use Magento\Sales\Model\Order;
use Magento\Sales\Model\Order\Invoice;
use PHPUnit\Framework\TestCase;

class ViewTest extends TestCase
{
    /**
     * @param bool $canReviewPayment
     * @param bool $canFetchUpdate
     * @param bool $expectedResult
     * @dataProvider isPaymentReviewDataProvider
     */
    public function testIsPaymentReview($canReviewPayment, $canFetchUpdate, $expectedResult)
    {
        // Create order mock
        $order = $this->getMockBuilder(Order::class)
            ->disableOriginalConstructor()
            ->getMock();
        $order->expects($this->any())->method('canReviewPayment')->willReturn($canReviewPayment);
        $order->expects(
            $this->any()
        )->method(
            'canFetchPaymentReviewUpdate'
        )->willReturn(
            $canFetchUpdate
        );

        // Create invoice mock
        $invoice = $this->getMockBuilder(
            Invoice::class
        )->disableOriginalConstructor()
            ->setMethods(
                ['getOrder']
            )->getMock();
        $invoice->expects($this->once())->method('getOrder')->willReturn($order);

        // Prepare block to test protected method
        $block = $this->getMockBuilder(
            View::class
        )->disableOriginalConstructor()
            ->setMethods(
                ['getInvoice']
            )->getMock();
        $block->expects($this->once())->method('getInvoice')->willReturn($invoice);
        $testMethod = new \ReflectionMethod(
            View::class,
            '_isPaymentReview'
        );
        $testMethod->setAccessible(true);

        $this->assertEquals($expectedResult, $testMethod->invoke($block));
    }

    /**
     * @return array
     */
    public function isPaymentReviewDataProvider()
    {
        return [
            [true, true, true],
            [true, false, true],
            [false, true, true],
            [false, false, false]
        ];
    }
}

Spamworldpro Mini