php spec test formularza

class FastOrderReturnCreatorSpec extends ObjectBehavior
{
    public function it_is_initializable(): void
    {
        $this->shouldHaveType(FastOrderReturnCreator::class);
        $this->shouldBeAnInstanceOf(OrderEditFormInterface::class);
    }

    public function let(
        FormFactoryInterface $formFactory,
        RouterInterface $router
    ): void {
        $this->beConstructedWith($formFactory, $router);
    }

    public function it_creates_form(
        FormFactoryInterface $formFactory,
        RouterInterface $router,
        OrderInterface $order,
        FormInterface $form
    ): void {
        $orderId = 1;
        $url = '/order/fast-order-return/1';

        $order->getId()->willReturn($orderId)->shouldBeCalledOnce();
        $router->generate('enp_enp0026_order_fast_return', ['orderId' => $orderId])->willReturn($url);

        $formFactory->createNamed(
            'order_return',
            FastOrderReturnType::class,
            null,
            [
                'action' => $url,
                'method' => Request::METHOD_PUT,
            ]
        )->willReturn($form);

        $this->createOrderEditForm($order)->shouldBe($form);
    }
Komentarze wyłączone