-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #667 from cakephp/table-scanner-ignore
Allow regex pattern for ignore
- Loading branch information
Showing
16 changed files
with
174 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright (c) Cake Software Foundation, Inc. (http://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. (http://cakefoundation.org) | ||
* @link http://cakephp.org CakePHP(tm) Project | ||
* @since 2.0.0 | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
namespace Bake\Test\TestCase\Utility; | ||
|
||
use Bake\Test\TestCase\TestCase; | ||
use Bake\Utility\TableScanner; | ||
use Cake\Datasource\ConnectionManager; | ||
|
||
class TableScannerTest extends TestCase | ||
{ | ||
/** | ||
* @var string[] | ||
*/ | ||
protected $fixtures = [ | ||
'plugin.Bake.TodoTasks', | ||
'plugin.Bake.TodoItems', | ||
]; | ||
|
||
/** | ||
* @var \Bake\Utility\TableScanner | ||
*/ | ||
protected $tableScanner; | ||
|
||
/** | ||
* @var \Cake\Database\Connection | ||
*/ | ||
protected $connection; | ||
|
||
/** | ||
* setUp method | ||
* | ||
* @return void | ||
*/ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->connection = ConnectionManager::get('test'); | ||
} | ||
|
||
/** | ||
* tearDown method | ||
* | ||
* @return void | ||
*/ | ||
public function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
unset($this->tableScanner); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function testListAll() | ||
{ | ||
$this->tableScanner = new TableScanner($this->connection); | ||
|
||
$result = $this->tableScanner->listAll(); | ||
$list = [ | ||
'todo_items' => true, | ||
'todo_tasks' => true, | ||
]; | ||
foreach ($list as $key => $expected) { | ||
if ($expected) { | ||
$this->assertArrayHasKey($key, $result); | ||
} else { | ||
$this->assertArrayNotHasKey($key, $result); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function testListUnskipped() | ||
{ | ||
$this->tableScanner = new TableScanner($this->connection, ['todo_items']); | ||
|
||
$result = $this->tableScanner->listUnskipped(); | ||
$list = [ | ||
'todo_items' => false, | ||
'todo_tasks' => true, | ||
]; | ||
foreach ($list as $key => $expected) { | ||
if ($expected) { | ||
$this->assertArrayHasKey($key, $result); | ||
} else { | ||
$this->assertArrayNotHasKey($key, $result); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function testListUnskippedRegex() | ||
{ | ||
$this->tableScanner = new TableScanner($this->connection, ['/tasks$/']); | ||
|
||
$result = $this->tableScanner->listUnskipped(); | ||
$list = [ | ||
'todo_items' => true, | ||
'todo_tasks' => false, | ||
]; | ||
foreach ($list as $key => $expected) { | ||
if ($expected) { | ||
$this->assertArrayHasKey($key, $result); | ||
} else { | ||
$this->assertArrayNotHasKey($key, $result); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters