ListDataTablesProviderCommandTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 17
dl 0
loc 44
c 1
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testExecute() 0 20 1
A test__construct() 0 10 1
1
<?php
2
3
/*
4
 * This file is part of the jquery-datatables-bundle package.
5
 *
6
 * (c) 2021 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\JQuery\DataTablesBundle\Tests\Command;
13
14
use Symfony\Bundle\FrameworkBundle\Console\Application;
15
use Symfony\Component\Console\Tester\CommandTester;
16
use WBW\Bundle\JQuery\DataTablesBundle\Command\ListDataTablesProviderCommand;
17
use WBW\Bundle\JQuery\DataTablesBundle\Manager\DataTablesManager;
18
use WBW\Bundle\JQuery\DataTablesBundle\Tests\AbstractWebTestCase;
19
20
/**
21
 * List DataTables provider command test.
22
 *
23
 * @author webeweb <https://github.com/webeweb>
24
 * @package WBW\Bundle\JQuery\DataTablesBundle\Tests\Command
25
 */
26
class ListDataTablesProviderCommandTest extends AbstractWebTestCase {
27
28
    /**
29
     * Test execute()
30
     *
31
     * @return void
32
     */
33
    public function testExecute(): void {
34
35
        $obj = new ListDataTablesProviderCommand();
36
        $obj->setDataTablesManager(static::$kernel->getContainer()->get(DataTablesManager::SERVICE_NAME . ".alias"));
37
        $obj->setTranslator(static::$kernel->getContainer()->get("translator"));
38
39
        // Set an Application mock.
40
        $application = new Application(static::$kernel);
41
        $application->add($obj);
42
43
        // Set a Command mock.
44
        $command = $application->find(ListDataTablesProviderCommand::COMMAND_NAME);
45
46
        // Set a Command tester.
47
        $commandTester = new CommandTester($command);
48
49
        $res = $commandTester->execute([
50
            "command" => $command->getName(),
51
        ]);
52
        $this->assertEquals(0, $res);
53
    }
54
55
    /**
56
     * Test __construct()
57
     *
58
     * @return void
59
     */
60
    public function test__construct(): void {
61
62
        $this->assertEquals("wbw.jquery.datatables.command.list_provider", ListDataTablesProviderCommand::SERVICE_NAME);
63
        $this->assertEquals("wbw:jquery:datatables:provider:list", ListDataTablesProviderCommand::COMMAND_NAME);
64
65
        $obj = new ListDataTablesProviderCommand();
66
67
        $this->assertEquals("List the DataTables providers", $obj->getDescription());
68
        $this->assertNotNull($obj->getHelp());
69
        $this->assertEquals(ListDataTablesProviderCommand::COMMAND_NAME, $obj->getName());
70
    }
71
}
72