c3.php throwing PHP Warnings with Vagrant
- Dominant language
- PHP
- Stars
- 73
- Forks
- 46
- PR merge metrics
- No merged PRs in 30d
Description
# Description #
I seem to receiving an error when trying to generate code coverage for functional tests inside Vagrant. The tests run and the code coverage generates fine but some test fail (namely any check on the response being valid JSON) due to `PHP Warnings` being thrown by the c3.php file.
## Steps ##
When ssh'd into vagrant, I run this command:
```
./vendor/bin/codecept run functional --coverage-html=blah tests/functional/Company/Product/CategoriesCest.php
```
All 3 tests fail when trying to assert `$I->seeResponseIsJson();`. When taking a look at the failure report generate in `tests/_output/tests.Company.Product.CategoriesCest.orderCategoriesDesc.fail.html` I see the following error:
```
Warning: file_put_contents(/var/www/phpapps/api.testurl.test/tests/_output/c3tmp/codecoverage.serialized): failed to open stream: Permission denied in /var/www/phpapps/api.testurl.test/c3.php on line 321
```
At line 321, `c3.php` is trying to execute:
https://github.com/Codeception/c3/blob/f08f20b0b6191f0c58be022c6f20d5b1cdc1004c/c3.php#L320-L322
which it can't complete because the permissions for c3tmp directory are as follows:
```
drwxr-xr-x 1 vagrant vagrant 68 Aug 10 08:55 c3tmp/
```
I'm puzzled as to why codeception wouldn't have permissions to write `codecoverage.serialized` in `c3tmp/` when it has created the directory itself... Furthermore, applying full read-write permissions to the `c3tmp/` via:
```
chmod -R 777 tests/_output/c3tmp/
```
results in even more `PHP Warnings` being generated seemingly from the same type of issue i.e incorrect file permissions, read-write lock etc. I've detailed these issues below:
```
Warning: fopen(/var/www/phpapps/api.testurl.test/tests/_output/c3tmp/codecoverage.serialized): failed to open stream: Permission denied in /var/www/phpapps/api.testurl.test/c3.php on line 184
Warning: flock() expects parameter 1 to be resource, boolean given in /var/www/phpapps/api.testurl.test/c3.php on line 185
Notice: Undefined variable: phpCoverage in /var/www/phpapps/api.testurl.test/c3.php on line 194
Fatal error: Call to a member function merge() on a non-object in /var/www/phpapps/api.testurl.test/c3.php on line 318
```
# Additional Information #
- **Vagrant:** Vagrant 1.9.2
- **PHP:** PHP 5.5.9-1ubuntu4.20 (cli)
- functional.suite.dist.yml
```Yaml
class_name: FunctionalTester
error_level: -1
coverage:
enabled: true
modules:
enabled: [PhpBrowser, REST, Asserts, FunctionalHelper]
config:
PhpBrowser:
url: http://api.testurl.test/
REST:
url: http://api.testurl.test/
```
- codeception.yml
```Yaml
actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
helpers: tests/_support
settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
coverage:
enabled: true
whitelist:
include:
- src/*
- public/*
exclude:
- src/Company/*/apidoc.json
- src/Company/*/apiDocVersioning/*
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.