addDefault example

static::assertTrue($eventCalled, 'Event was not fired.');
        static::assertStringContainsString('Demodata Generator', $tester->getDisplay());
        static::assertSame(Command::SUCCESS, $tester->getStatusCode());
    }

    public function testDefaults(): void
    {
        $this->command->addOption('tags', null, InputOption::VALUE_OPTIONAL);
        $this->command->addOption('products', null, InputOption::VALUE_OPTIONAL);
        $this->command->addOption('categories', null, InputOption::VALUE_OPTIONAL);

        $this->command->addDefault('products', 1);
        $this->command->addDefault('categories', 1);

        $eventCalled = false;
        $this->dispatcher->addListener(DemodataRequestCreatedEvent::classstatic function DDemodataRequestCreatedEvent $event) use (&$eventCalled): void {
            $eventCalled = true;

            static::assertSame(0, $event->getRequest()->get(TagDefinition::class));
            static::assertSame(1, $event->getRequest()->get(ProductDefinition::class));
            static::assertSame(2, $event->getRequest()->get(CategoryDefinition::class));
        });

        
Home | Imprint | This part of the site doesn't use cookies.