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() |
|
|
|
|
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() |
|
|
|
|
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() |
|
|
|
|
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
|
|
|
|
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.