-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathModelAllCommandTest.php
More file actions
102 lines (90 loc) · 2.88 KB
/
ModelAllCommandTest.php
File metadata and controls
102 lines (90 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
declare(strict_types=1);
/**
* CakePHP : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP Project
* @since 2.0.0
* @license https://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Bake\Test\TestCase\Command;
use Bake\Test\TestCase\TestCase;
use Bake\Utility\SubsetSchemaCollection;
use Cake\Console\CommandInterface;
use Cake\Datasource\ConnectionManager;
use Cake\Utility\Inflector;
/**
* ModelAllCommand test class
*/
class ModelAllCommandTest extends TestCase
{
/**
* fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.Bake.TodoTasks',
'plugin.Bake.TodoItems',
];
/**
* @var array<string>
*/
protected array $tables = ['todo_tasks', 'todo_items'];
/**
* setUp method
*
* @return void
*/
public function setUp(): void
{
parent::setUp();
$this->setAppNamespace('Bake\Test\App');
$connection = ConnectionManager::get('test');
$subsetCollection = new SubsetSchemaCollection($connection->getSchemaCollection(), $this->tables);
$connection->setSchemaCollection($subsetCollection);
}
/**
* teardown method
*
* @return void
*/
public function tearDown(): void
{
parent::tearDown();
$connection = ConnectionManager::get('test');
$connection->setSchemaCollection($connection->getSchemaCollection()->getInnerCollection());
$this->getTableLocator()->clear();
}
/**
* test execute
*
* @return void
*/
public function testExecute()
{
foreach ($this->tables as $table) {
$plural = Inflector::camelize($table);
$singular = Inflector::singularize($plural);
$this->generatedFiles[] = APP . "Model/Entity/{$singular}.php";
$this->generatedFiles[] = ROOT . "tests/Fixture/{$plural}Fixture.php";
}
$this->exec('bake model all --connection test --no-table --no-test');
$this->assertExitCode(CommandInterface::CODE_SUCCESS);
$this->assertFilesExist($this->generatedFiles);
$this->assertFileDoesNotExist(
APP . 'Model/Table/TodoItemsTable.php',
'Table should not be created as options should be forwarded',
);
$this->assertFileDoesNotExist(
ROOT . 'tests/TestCase/Model/Table/TodoItemsTableTest.php',
'Table test should not be created as options should be forwarded',
);
}
}