Skip to content

Commit

Permalink
Issue #44 Ignore views from the truncation
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloelcolombiano committed May 24, 2021
1 parent e2fd2a0 commit c994517
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"php": ">=7.0",
"cakephp/cakephp": "^3.7",
"ext-pdo": "*",
"vierge-noire/cakephp-test-migrator": "^1.2"
"vierge-noire/cakephp-test-migrator": "^1.3"
},
"require-dev": {
"cakephp/migrations": "^2.3",
Expand Down
3 changes: 2 additions & 1 deletion src/Sniffer/BaseTableSniffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use Cake\Database\Exception;
use Cake\Datasource\ConnectionInterface;
use CakephpTestMigrator\SchemaCleaner;

abstract class BaseTableSniffer
{
Expand Down Expand Up @@ -183,7 +184,7 @@ public function getAllTables(bool $forceFetch = false): array
*/
public function fetchAllTables(): array
{
return $this->getConnection()->getSchemaCollection()->listTables();
return (new SchemaCleaner())->listTables($this->getConnection());
}

/**
Expand Down
22 changes: 8 additions & 14 deletions tests/TestCase/FixtureInjectorSkipTruncationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
use CakephpTestSuiteLight\FixtureInjector;
use CakephpTestSuiteLight\FixtureManager;
use CakephpTestSuiteLight\SkipTablesTruncation;
use TestApp\Model\Table\CountriesTable;

Expand All @@ -25,29 +23,25 @@ class FixtureInjectorSkipTruncationTest extends TestCase
use SkipTablesTruncation;

/**
* @var FixtureManager
* @var CountriesTable
*/
public $FixtureManager;
public $Countries;

/**
* @var CountriesTable
* @var int
*/
public $Countries;
public static $nInitialCities;

/**
* Makes sure that the country table starts empty
* Get the original number of countries
*/
public static function setUpBeforeClass()
{
TableRegistry::getTableLocator()->get('Countries')->deleteAll(['1 = 1']);
self::$nInitialCities = TableRegistry::getTableLocator()->get('Countries')->find()->count();
}

public function setUp()
{
$this->FixtureManager = new FixtureInjector(
$this->createMock(FixtureManager::class)
);

$this->Countries = TableRegistry::getTableLocator()->get('Countries');
}

Expand All @@ -71,6 +65,6 @@ public function testTruncationSkipped(int $expected)
{
$country = $this->Countries->newEntity(['name' => 'foo']);
$this->Countries->saveOrFail($country);
$this->assertSame($expected, $this->Countries->find()->count());
$this->assertSame($expected + self::$nInitialCities, $this->Countries->find()->count());
}
}
}

0 comments on commit c994517

Please sign in to comment.