-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 #2702 from asgrim/filter-tablenames-in-db2-schema-…
…manager Added missing filtering of table name assets in DB2SchemaManager
- Loading branch information
Showing
2 changed files
with
72 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\DBAL\Schema; | ||
|
||
use Doctrine\Common\EventManager; | ||
use Doctrine\DBAL\Configuration; | ||
use Doctrine\DBAL\Connection; | ||
use Doctrine\DBAL\Driver; | ||
use Doctrine\DBAL\Platforms\DB2Platform; | ||
use Doctrine\DBAL\Schema\DB2SchemaManager; | ||
|
||
/** | ||
* @covers \Doctrine\DBAL\Schema\DB2SchemaManager | ||
*/ | ||
final class DB2SchemaManagerTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var Connection|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $conn; | ||
|
||
/** | ||
* @var DB2SchemaManager | ||
*/ | ||
private $manager; | ||
|
||
protected function setUp() | ||
{ | ||
$eventManager = new EventManager(); | ||
$driverMock = $this->getMock(Driver::class); | ||
$platform = $this->getMock(DB2Platform::class); | ||
$this->conn = $this->getMock( | ||
Connection::class, | ||
['fetchAll'], | ||
[['platform' => $platform], $driverMock, new Configuration(), $eventManager] | ||
); | ||
$this->manager = new DB2SchemaManager($this->conn); | ||
} | ||
|
||
/** | ||
* @group DBAL-2701 | ||
* @see https://github.com/doctrine/dbal/issues/2701 | ||
* @return void | ||
*/ | ||
public function testListTableNamesFiltersAssetNamesCorrectly() | ||
{ | ||
$this->conn->getConfiguration()->setFilterSchemaAssetsExpression('/^(?!T_)/'); | ||
$this->conn->expects($this->once())->method('fetchAll')->will($this->returnValue([ | ||
[ | ||
'name' => 'FOO', | ||
], | ||
[ | ||
'name' => 'T_FOO', | ||
], | ||
[ | ||
'name' => 'BAR', | ||
], | ||
[ | ||
'name' => 'T_BAR', | ||
], | ||
])); | ||
|
||
$this->assertSame( | ||
[ | ||
'FOO', | ||
'BAR', | ||
], | ||
$this->manager->listTableNames() | ||
); | ||
} | ||
} |