15 changes: 15 additions & 0 deletions src/Core/Framework/Test/TestCaseBase/BasicTestDataBehaviour.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Shopware\Core\Framework\Test\TestCaseBase;

use Shopware\Core\Checkout\Order\OrderStates;
use Shopware\Core\Checkout\Payment\PaymentMethodEntity;
use Shopware\Core\Checkout\Shipping\ShippingMethodEntity;
use Shopware\Core\Defaults;
Expand Down Expand Up @@ -180,4 +181,18 @@ protected function getValidTaxId(): string

return $repository->searchIds($criteria, Context::createDefaultContext())->getIds()[0];
}

protected function getStateMachineState(string $stateMachine = OrderStates::STATE_MACHINE, string $state = OrderStates::STATE_OPEN): string
{
/** @var EntityRepositoryInterface $repository */
$repository = $this->getContainer()->get('state_machine_state.repository');

$criteria = new Criteria();
$criteria
->setLimit(1)
->addFilter(new EqualsFilter('technicalName', $state))
->addFilter(new EqualsFilter('stateMachine.technicalName', $stateMachine));

return $repository->searchIds($criteria, Context::createDefaultContext())->getIds()[0];
}
}