Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #3028 #3049

Merged
merged 1 commit into from Apr 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,7 @@

#### 2.1.9

* [Laravel] Fixed issue where non-existing services were called in _before and _after methods. See #3028.
* [WebDriver] fixed using `saveSessionSnapshot` with codecoverage. Closes #2923
* [ZF2] create new instance of Application for each request

Expand Down
2 changes: 1 addition & 1 deletion src/Codeception/Lib/Connector/Laravel4.php
Expand Up @@ -71,7 +71,7 @@ private function initialize()
// Store a reference to the database object
// so the database connection can be reused during tests
$oldDb = null;
if ($this->app['db'] && $this->app['db']->connection()) {
if (isset($this->app['db']) && $this->app['db']->connection()) {
$oldDb = $this->app['db'];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Codeception/Lib/Connector/Laravel5.php
Expand Up @@ -107,7 +107,7 @@ private function initialize($request = null)
// Store a reference to the database object
// so the database connection can be reused during tests
$this->oldDb = null;
if ($this->app['db'] && $this->app['db']->connection()) {
if (isset($this->app['db']) && $this->app['db']->connection()) {
$this->oldDb = $this->app['db'];
}

Expand Down
12 changes: 6 additions & 6 deletions src/Codeception/Module/Laravel4.php
Expand Up @@ -128,7 +128,7 @@ public function _before(TestCase $test)
{
$this->client = new LaravelConnector($this);

if ($this->app['db'] && $this->cleanupDatabase()) {
if (isset($this->app['db']) && $this->cleanupDatabase()) {
$this->app['db']->beginTransaction();
}

Expand All @@ -144,24 +144,24 @@ public function _before(TestCase $test)
*/
public function _after(TestCase $test)
{
if ($this->app['db'] && $this->cleanupDatabase()) {
if (isset($this->app['db']) && $this->cleanupDatabase()) {
$this->app['db']->rollback();
}

if ($this->app['auth']) {
if (isset($this->app['auth'])) {
$this->app['auth']->logout();
}

if ($this->app['session']) {
if (isset($this->app['session'])) {
$this->app['session']->flush();
}

if ($this->app['cache']) {
if (isset($this->app['cache'])) {
$this->app['cache']->flush();
}

// disconnect from DB to prevent "Too many connections" issue
if ($this->app['db']) {
if (isset($this->app['db'])) {
$this->app['db']->disconnect();
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/Codeception/Module/Laravel5.php
Expand Up @@ -140,7 +140,7 @@ public function _before(\Codeception\TestCase $test)
{
$this->client = new LaravelConnector($this);

if ($this->app['db'] && $this->config['cleanup']) {
if (isset($this->app['db']) && $this->config['cleanup']) {
$this->app['db']->beginTransaction();
}
}
Expand All @@ -152,24 +152,24 @@ public function _before(\Codeception\TestCase $test)
*/
public function _after(\Codeception\TestCase $test)
{
if ($this->app['db'] && $this->config['cleanup']) {
if (isset($this->app['db']) && $this->config['cleanup']) {
$this->app['db']->rollback();
}

if ($this->app['auth']) {
if (isset($this->app['auth'])) {
$this->app['auth']->logout();
}

if ($this->app['session']) {
if (isset($this->app['session'])) {
$this->app['session']->flush();
}

if ($this->app['cache']) {
if (isset($this->app['cache'])) {
$this->app['cache']->flush();
}

// disconnect from DB to prevent "Too many connections" issue
if ($this->app['db']) {
if (isset($this->app['db'])) {
$this->app['db']->disconnect();
}
}
Expand Down