SpreadsheetCommandTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 75 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 36
loc 48
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testEmptySheet() 12 12 1
A testErrorSpreadsheetFile() 12 12 1
A testSuccessful() 12 12 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * @link https://github.com/vuongxuongminh/migrate-phone-number
4
 * @copyright Copyright (c) 2018 Vuong Xuong Minh
5
 * @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php)
6
 */
7
8
namespace VXM\MPN\Tester;
9
10
use VXM\MPN\SpreadsheetCommand;
11
use Symfony\Component\Console\Tester\CommandTester;
12
13
/**
14
 * Lớp SpreadsheetCommandTest thực hiện test database command.
15
 *
16
 * @author Vuong Minh <[email protected]>
17
 * @since 1.0
18
 */
19
class SpreadsheetCommandTest extends BaseTestCase
20
{
21
22 View Code Duplication
    public function testEmptySheet()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
    {
24
        $commandTester = new CommandTester($this->app->get('migrate:ss'));
25
        $commandTester->setInputs([
26
            'y',
27
            __DIR__ . '/resources/phone-numbers.xlsx',
28
            '2:A, 2:C'
29
        ]);
30
        $commandTester->execute(['command' => 'migrate:ss']);
31
        $output = $commandTester->getDisplay(true);
32
        $this->assertContains('Bỏ qua sheet', $output);
33
    }
34
35 View Code Duplication
    public function testErrorSpreadsheetFile()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
    {
37
        $commandTester = new CommandTester($this->app->get('migrate:ss'));
38
        $commandTester->setInputs([
39
            'y',
40
            __DIR__ . '/resources/phone-numbers.xlsxx',
41
            '0:A, 0:C'
42
        ]);
43
        $commandTester->execute(['command' => 'migrate:ss']);
44
        $output = $commandTester->getDisplay(true);
45
        $this->assertContains('Đường dẫn thư mục không hợp lệ hoặc file không đúng định dạng!', $output);
46
    }
47
48
    /**
49
     * @depends testEmptySheet
50
     * @depends testErrorSpreadsheetFile
51
     */
52 View Code Duplication
    public function testSuccessful()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
53
    {
54
        $commandTester = new CommandTester($this->app->get('migrate:ss'));
55
        $commandTester->setInputs([
56
            'y',
57
            __DIR__ . '/resources/phone-numbers.xlsx',
58
            '0:A, 0:C'
59
        ]);
60
        $commandTester->execute(['command' => 'migrate:ss']);
61
        $output = $commandTester->getDisplay(true);
62
        $this->assertContains('Hoàn tất chuyển đổi dữ liệu trên sheet', $output);
63
    }
64
65
66
}
67