Fireguard\Report\Exporters\AbstractPhantomExporterTest::testAddCommandOption PHP Method

testAddCommandOption() public method

    public function testAddCommandOption()
    {
        $exporter = $this->getMockForAbstractClass(AbstractPhantomExporter::class);
        $exporter->setConfigValidOptions(['web-security' => 'bool', 'disk-cache' => 'bool', 'local-storage-path' => 'string', 'test-option' => 'not-validated-type', 'ssl-protocol' => ['sslv3', 'sslv2', 'tlsv1', 'any']]);
        // Ignore Invalid Option
        $options = $exporter->getCommandOptions();
        $exporter->addCommandOption('command-option-include', true);
        $this->assertEquals($options, $exporter->getCommandOptions());
        // Ignore Invalid Value
        $exporter->addCommandOption('web-security', 'invalid-expected-bool');
        $this->assertEquals($options, $exporter->getCommandOptions());
        // Define Valid Value for Bool
        $exporter->addCommandOption('disk-cache', true);
        $this->assertArrayHasKey('disk-cache', $exporter->getCommandOptions());
        // Define Valid Value for Array
        $exporter->addCommandOption('ssl-protocol', 'any');
        $options = $exporter->getCommandOptions();
        $this->assertArrayHasKey('ssl-protocol', $options);
        $this->assertEquals('any', $options['ssl-protocol']);
        // Define Valid Value for String
        $exporter->addCommandOption('local-storage-path', 'path-string');
        $options = $exporter->getCommandOptions();
        $this->assertArrayHasKey('local-storage-path', $options);
        $this->assertEquals('path-string', $options['local-storage-path']);
        // Define Valid Value for not validated format
        $exporter->addCommandOption('test-option', 'any-value');
        $options = $exporter->getCommandOptions();
        $this->assertArrayHasKey('test-option', $options);
        $this->assertEquals('any-value', $options['test-option']);
    }