Code Duplication    Length = 12-15 lines in 4 locations

Tests/Command/CreateOrganizationCommandTest.php 2 locations

@@ 41-52 (lines=12) @@
38
    /**
39
     * @covers SWP\Bundle\MultiTenancyBundle\Command\CreateOrganizationCommand
40
     */
41
    public function testExecuteWhenCreatingNewOrganization()
42
    {
43
        $this->dialog->setInputStream($this->getInputStream("Test\n"));
44
        $this->command->setContainer($this->getMockContainer(null, new Organization(), 'Test'));
45
        $this->commandTester = new CommandTester($this->command);
46
        $this->commandTester->execute(['command' => $this->command->getName()]);
47
48
        $this->assertRegExp(
49
            '/Please enter name:Organization Test has been created and enabled!/',
50
            $this->commandTester->getDisplay()
51
        );
52
    }
53
54
    /**
55
     * @covers SWP\Bundle\MultiTenancyBundle\Command\CreateOrganizationCommand
@@ 91-105 (lines=15) @@
88
    /**
89
     * @covers SWP\Bundle\MultiTenancyBundle\Command\CreateOrganizationCommand
90
     */
91
    public function testExecuteDisabledOrganization()
92
    {
93
        $this->dialog->setInputStream($this->getInputStream("Example\n"));
94
        $this->command->setContainer($this->getMockContainer(null, new Organization(), 'Example'));
95
        $this->commandTester = new CommandTester($this->command);
96
        $this->commandTester->execute([
97
            'command' => $this->command->getName(),
98
            '--disabled' => true,
99
        ]);
100
101
        $this->assertRegExp(
102
            '/Please enter name:Organization Example has been created and disabled!/',
103
            $this->commandTester->getDisplay()
104
        );
105
    }
106
107
    private function getMockContainer($mockOrganization = null, $mockedOrganizationInFactory = null, $name = OrganizationInterface::DEFAULT_NAME)
108
    {

Tests/Command/CreateTenantCommandTest.php 2 locations

@@ 46-57 (lines=12) @@
43
    /**
44
     * @covers SWP\Bundle\MultiTenancyBundle\Command\CreateTenantCommand
45
     */
46
    public function testExecuteWhenCreatingNewTenant()
47
    {
48
        $this->dialog->setInputStream($this->getInputStream("subdomain\nTest\n123456\n"));
49
        $this->command->setContainer($this->getMockContainer(null, new Organization(), new Tenant(), 'subdomain'));
50
        $this->commandTester = new CommandTester($this->command);
51
        $this->commandTester->execute(['command' => $this->command->getName()]);
52
53
        $this->assertRegExp(
54
            '/Please enter subdomain:Please enter name:Please enter organization:Tenant Test has been created and enabled!/',
55
            $this->commandTester->getDisplay()
56
        );
57
    }
58
59
    /**
60
     * @covers SWP\Bundle\MultiTenancyBundle\Command\CreateTenantCommand
@@ 116-130 (lines=15) @@
113
    /**
114
     * @covers SWP\Bundle\MultiTenancyBundle\Command\CreateTenantCommand
115
     */
116
    public function testExecuteDisabledTenant()
117
    {
118
        $this->dialog->setInputStream($this->getInputStream("example\nExample\n123456\n"));
119
        $this->command->setContainer($this->getMockContainer(null, new Organization(), new Tenant(), 'example'));
120
        $this->commandTester = new CommandTester($this->command);
121
        $this->commandTester->execute([
122
            'command' => $this->command->getName(),
123
            '--disabled' => true,
124
        ]);
125
126
        $this->assertRegExp(
127
            '/Please enter subdomain:Please enter name:Please enter organization:Tenant Example has been created and disabled!/',
128
            $this->commandTester->getDisplay()
129
        );
130
    }
131
132
    private function getMockContainer($mockTenant = null, $mockOrganization = null, $mockedTenantInFactory = null, $subdomain = 'default')
133
    {