Skip to content

Commit

Permalink
Fix mutation tests by adding a missing unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Zales0123 committed Jun 14, 2024
1 parent 3ceb3bd commit 6f345e4
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 3 deletions.
10 changes: 9 additions & 1 deletion infection.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
"source": {
"directories": [
"src"
],
"excludes": [
"Controller",
"DependencyInjection/SetonoSyliusOrderEditExtension.php",
"Exception",
"EventSubscriber",
"Form"
]
},
"logs": {
Expand All @@ -12,5 +19,6 @@
}
},
"minMsi": 100.00,
"minCoveredMsi": 100.00
"minCoveredMsi": 100.00,
"testFrameworkOptions": "--testsuite=unit"
}
7 changes: 5 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
</include>
</coverage>
<testsuites>
<testsuite name="SetonoSyliusOrderEditPlugin Test Suite">
<directory>tests</directory>
<testsuite name="unit">
<directory>tests/Unit</directory>
</testsuite>
<testsuite name="functional">
<directory>tests/Functional</directory>
</testsuite>
</testsuites>
<php>
Expand Down
50 changes: 50 additions & 0 deletions tests/Unit/OrderProcessing/OrderPaymentProcessorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

declare(strict_types=1);

namespace Setono\SyliusOrderEditPlugin\Tests\Unit\OrderProcessing;

use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Setono\SyliusOrderEditPlugin\OrderProcessing\OrderPaymentProcessor;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Order\Processor\OrderProcessorInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;

final class OrderPaymentProcessorTest extends TestCase
{
use ProphecyTrait;

public function testItDoesNotAllowToProcessOrderIfItsEdited(): void
{
$orderProcessor = $this->prophesize(OrderProcessorInterface::class);
$requestStack = $this->prophesize(RequestStack::class);
$request = new Request([], [], ['_route' => 'setono_sylius_order_edit_admin_update']);
$requestStack->getCurrentRequest()->willReturn($request);

$processor = new OrderPaymentProcessor($orderProcessor->reveal(), $requestStack->reveal());

$order = $this->prophesize(OrderInterface::class);

$orderProcessor->process($order)->shouldNotBeCalled();

$processor->process($order->reveal());
}

public function testItDoesNothingIfItsDifferentRoute(): void
{
$orderProcessor = $this->prophesize(OrderProcessorInterface::class);
$requestStack = $this->prophesize(RequestStack::class);
$request = new Request([], [], ['_route' => 'some_other_route']);
$requestStack->getCurrentRequest()->willReturn($request);

$processor = new OrderPaymentProcessor($orderProcessor->reveal(), $requestStack->reveal());

$order = $this->prophesize(OrderInterface::class);

$orderProcessor->process($order)->shouldBeCalled();

$processor->process($order->reveal());
}
}

0 comments on commit 6f345e4

Please sign in to comment.