Skip to content

Fix buggy tearDown() with MySQL - #321

Merged
kenjis merged 1 commit into
kenjis:masterfrom
GSA:patch-2
Jan 30, 2020
Merged

Fix buggy tearDown() with MySQL#321
kenjis merged 1 commit into
kenjis:masterfrom
GSA:patch-2

Conversation

@mogul

@mogul mogul commented Jan 29, 2020

Copy link
Copy Markdown

Fixes a problem where calling tearDown also results in a PHP Error:

Uncaught Error: Call to a member function real_escape_string() on bool in [...]/vendor/codeigniter/framework/system/database/drivers/mysqli/mysqli_driver.php:393

Fixes a problem where calling `tearDown` results in a PHP Error:
```
Uncaught Error: Call to a member function real_escape_string() on bool in [...]/vendor/codeigniter/framework/system/database/drivers/mysqli/mysqli_driver.php:393
```
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.01%) to 56.549% when pulling 84c82b6 on mogul:patch-2 into 6a823bb on kenjis:master.

mogul added a commit to GSA/project-open-data-dashboard that referenced this pull request Jan 29, 2020
This branch depends on a fix in the upstream testing framework that I encountered. This change utilizes [Bret's fork with the fix](https://github.com/mogul/ci-phpunit-test/tree/patch-2) while [the PR for the fix](kenjis/ci-phpunit-test#321) is pending. This change can be rolled out once the upstream merge happens.
mogul added a commit to GSA/project-open-data-dashboard that referenced this pull request Jan 29, 2020
This reverts the change in d0098bf. Don't merge it until the [upstream PR](kenjis/ci-phpunit-test#321)
@mogul

mogul commented Jan 29, 2020

Copy link
Copy Markdown
Author

To see this bug in action, check out this PR/branch, then make up update-dependencies test

mogul added a commit to GSA/project-open-data-dashboard that referenced this pull request Jan 29, 2020
This reverts the change in d0098bf. Don't merge it until the [upstream PR](kenjis/ci-phpunit-test#321)
@kenjis

kenjis commented Jan 30, 2020

Copy link
Copy Markdown
Owner

@mogul Thank you. I'm going to check it.

@kenjis

kenjis commented Jan 30, 2020

Copy link
Copy Markdown
Owner
> ./vendor/bin/phpunit --no-coverage --testdox -c application/tests
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.

Offices
 ✔ Office details page is valid without crawls
 ✘ Office list includes omb monitored offices
   │
   │ Error: Call to a member function real_escape_string() on bool
   │ 
   │ /var/www/app/vendor/codeigniter/framework/system/database/drivers/mysqli/mysqli_driver.php:393
   │ /var/www/app/vendor/codeigniter/framework/system/database/DB_driver.php:1143
   │ /var/www/app/vendor/codeigniter/framework/system/database/DB_driver.php:1108
   │ /var/www/app/vendor/codeigniter/framework/system/database/DB_query_builder.php:683
   │ /var/www/app/vendor/codeigniter/framework/system/database/DB_query_builder.php:623
   │ /var/www/app/vendor/codeigniter/framework/system/database/DB_query_builder.php:2183
   │ /var/www/app/vendor/kenjis/ci-phpunit-test/application/tests/_ci_phpunit_test/CIPHPUnitTestDbTestCase.php:61
   │ /var/www/app/vendor/phpunit/phpunit/phpunit:61
   │ 
 ✔ Detail 404s on bad milestone with data set #0
 ✔ Detail 404s on bad milestone with data set #1
 ✔ Detail 404s on bad milestone with data set #2
 ✔ Detail 404s on bad milestone with data set #3
 ✔ Detail 404s on bad milestone with data set #4
 ✔ Detail 404s on bad milestone with data set #5
 ✔ Detail 404s on bad milestone with data set #6
 ✔ Detail 404s on bad milestone with data set #7

Strapping
 ✔ Strapped code does not generate errors
 ✔ Main nav returns 200 with data set "Home"
 ✔ Main nav returns 200 with data set "Agencies"
 ✔ Main nav returns 200 with data set "Validator"
 ✔ Main nav returns 200 with data set "Converters > ExportAPI"
 ✔ Main nav returns 200 with data set "Converters > CSV Converter"
 ✔ Main nav returns 200 with data set "Converters > Schema Converter"
 ✔ Main nav returns 200 with data set "Converters > Data.json merger"
 ✔ Main nav returns 200 with data set "Rubric"
 ✔ Main nav returns 200 with data set "Help > Docs"
 ✔ Main nav returns 200 with data set "About"

Welcome
 ✔ Generates the expected title
 ✔ Generates a 404 in response to requests for a missing method
 ✔ Confirms the application path is set correctly

APIHelper
 ✔ Filter remote url tolerates unresolvable hosts

Migrations
 ✔ Omb monitored offices are present and flagged in database

CampaignModel
 ✔ Archive of bad link fails
Creating directory /var/www/app/archive/digitalstrategy/2020-01-29
Attempting to download https://this.is.a.bad.url/data.json to /var/www/app/archive/digitalstrategy/2020-01-29/somefilename.json.json
Could not read from https://this.is.a.bad.url/data.json

Time: 9.51 seconds, Memory: 12.00 MB

Summary of non-successful tests:

Offices
 ✘ Office list includes omb monitored offices
   │
   │ Error: Call to a member function real_escape_string() on bool
   │ 
   │ /var/www/app/vendor/codeigniter/framework/system/database/drivers/mysqli/mysqli_driver.php:393
   │ /var/www/app/vendor/codeigniter/framework/system/database/DB_driver.php:1143
   │ /var/www/app/vendor/codeigniter/framework/system/database/DB_driver.php:1108
   │ /var/www/app/vendor/codeigniter/framework/system/database/DB_query_builder.php:683
   │ /var/www/app/vendor/codeigniter/framework/system/database/DB_query_builder.php:623
   │ /var/www/app/vendor/codeigniter/framework/system/database/DB_query_builder.php:2183
   │ /var/www/app/vendor/kenjis/ci-phpunit-test/application/tests/_ci_phpunit_test/CIPHPUnitTestDbTestCase.php:61
   │ /var/www/app/vendor/phpunit/phpunit/phpunit:61
   │ 

ERRORS!
Tests: 27, Assertions: 28, Errors: 1.
Script ./vendor/bin/phpunit --no-coverage --testdox -c application/tests handling the test event returned with error code 2
make: *** [unit-tests] Error 2

@kenjis

kenjis commented Jan 30, 2020

Copy link
Copy Markdown
Owner

After applied the fix:

$ make test
bin/composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
docker-compose exec app composer test
> ./vendor/bin/phpunit --no-coverage --testdox -c application/tests
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.

Offices
 ✔ Office details page is valid without crawls
 ✔ Office list includes omb monitored offices
 ✔ Detail 404s on bad milestone with data set #0
 ✔ Detail 404s on bad milestone with data set #1
 ✔ Detail 404s on bad milestone with data set #2
 ✔ Detail 404s on bad milestone with data set #3
 ✔ Detail 404s on bad milestone with data set #4
 ✔ Detail 404s on bad milestone with data set #5
 ✔ Detail 404s on bad milestone with data set #6
 ✔ Detail 404s on bad milestone with data set #7

Strapping
 ✔ Strapped code does not generate errors
 ✔ Main nav returns 200 with data set "Home"
 ✔ Main nav returns 200 with data set "Agencies"
 ✔ Main nav returns 200 with data set "Validator"
 ✔ Main nav returns 200 with data set "Converters > ExportAPI"
 ✔ Main nav returns 200 with data set "Converters > CSV Converter"
 ✔ Main nav returns 200 with data set "Converters > Schema Converter"
 ✔ Main nav returns 200 with data set "Converters > Data.json merger"
 ✔ Main nav returns 200 with data set "Rubric"
 ✔ Main nav returns 200 with data set "Help > Docs"
 ✔ Main nav returns 200 with data set "About"

Welcome
 ✔ Generates the expected title
 ✔ Generates a 404 in response to requests for a missing method
 ✔ Confirms the application path is set correctly

APIHelper
 ✔ Filter remote url tolerates unresolvable hosts

Migrations
 ✔ Omb monitored offices are present and flagged in database

CampaignModel
 ✔ Archive of bad link fails
Attempting to download https://this.is.a.bad.url/data.json to /var/www/app/archive/digitalstrategy/2020-01-29/somefilename.json.json
Could not read from https://this.is.a.bad.url/data.json

Time: 3.45 seconds, Memory: 10.00 MB

OK (27 tests, 28 assertions)

@kenjis
kenjis merged commit 58f6b1a into kenjis:master Jan 30, 2020
@mogul
mogul deleted the patch-2 branch January 30, 2020 02:21
@mogul

mogul commented Jan 30, 2020

Copy link
Copy Markdown
Author

Excellent! Thank you for the rapid response.

@kenjis kenjis added the bug label Jan 30, 2020
kenjis added a commit that referenced this pull request Feb 5, 2020
Fix buggy tearDown() with MySQL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants