Skip to content

Commit

Permalink
Cake3 next (#29)
Browse files Browse the repository at this point in the history
* #14 cake3 make perm mode default (#15)

* #7 Removes the CakePHP fixture init (#9) (#11)

Co-authored-by: Juan Pablo Ramirez <>

* #14 Makes the dirty table collector permanent per default

* #14 Test fix

Co-authored-by: Juan Pablo Ramirez <>

* #24 Fix connection alias issue (#26)

Co-authored-by: Juan Pablo Ramirez <>

Co-authored-by: Juan Pablo Ramirez <>
  • Loading branch information
pabloelcolombiano authored Feb 14, 2021
1 parent 48a35fb commit d3d2ca8
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@ Licensed under The MIT License Redistributions of files must retain the above co

## Authors
* Juan Pablo Ramirez
* Nicolas Masson
* Nicolas Masson
4 changes: 4 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

<!-- Add any additional test suites you want to run here -->
<testsuites>
<!-- This test should run once first to ensure that the connections are well aliased -->
<testsuite name="Init">
<file>./tests/TestCase/FixtureInjectorTest.php</file>
</testsuite>
<testsuite name="Default">
<directory>./tests/TestCase/</directory>
</testsuite>
Expand Down
4 changes: 3 additions & 1 deletion src/FixtureInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public function __construct(FixtureManager $manager, bool $withStatistics = fals
* @param TestSuite $suite
*/
public function startTestSuite(TestSuite $suite)
{}
{
$this->_fixtureManager->aliasConnections();
}

/**
* Cleanup before test starts
Expand Down
7 changes: 5 additions & 2 deletions src/FixtureManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class FixtureManager extends BaseFixtureManager
/**
* @var bool
*/
private static $_configIsLoaded = false;
private static $aliasConnectionIsLoaded = false;

/**
* @var array|null
Expand All @@ -51,7 +51,10 @@ public function getConnection($name = 'test')
*/
public function aliasConnections()
{
$this->_aliasConnections();
if (!self::$aliasConnectionIsLoaded) {
$this->_aliasConnections();
self::$aliasConnectionIsLoaded = true;
}
}

/**
Expand Down
9 changes: 6 additions & 3 deletions tests/TestCase/FixtureInjectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace TestCase;

use Cake\ORM\TableRegistry;
use CakephpTestSuiteLight\FixtureInjector;
use CakephpTestSuiteLight\FixtureManager;
use PHPUnit\Framework\TestCase;
Expand All @@ -37,7 +38,8 @@ public function testStartTestWithPhpunitTestCase()
{
$test = $this->createMock(TestCase::class);
$this->FixtureInjector->startTest($test);
$this->assertTrue(true);
$configName = TableRegistry::getTableLocator()->get('Countries')->getConnection()->configName();
$this->assertSame('test', $configName);
}

/**
Expand All @@ -48,7 +50,8 @@ public function testStartTestWithCakeTestCase()
$test = $this->createMock(\Cake\TestSuite\TestCase::class);
$test->fixtures = null;
$this->FixtureInjector->startTest($test);
$this->assertTrue(true);
$configName = TableRegistry::getTableLocator()->get('Countries')->getConnection()->configName();
$this->assertSame('test', $configName);
}

/**
Expand All @@ -71,4 +74,4 @@ public function testEndTestWithCakeTestCase()
$this->FixtureInjector->endTest($test, 0);
$this->assertTrue(true);
}
}
}

0 comments on commit d3d2ca8

Please sign in to comment.