Welcome Guest, Not a member yet? Register   Sign In
PHPUnit code coverage report

I've been working on making some PHPUnit tests. The tests so far have been working fine, but when I try code coverage report I am getting the following error:

Quote:phpunit tests/CustomerProfileTest.php
PHPUnit 9.5.28 by Sebastian Bergmann and contributors.

.................                                                17 / 17 (100%)

Time: 00:00.533, Memory: 48.78 MB

OK (17 tests, 26 assertions)

Generating code coverage report in Clover XML format ... No direct script access allowed
I get the "No direct script access allowed" and the coverage files are not generated.
I am not even sure if this is related to CI4 (CI 4.3.1). "No direct script access allowed" was a thing in CI3.

I tried "phpunit tests/CustomerProfileTest.php --colors --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/ -d memory_limit=1024m" and got exactly the same result.

Any ideas?


(This post was last modified: 01-15-2023, 08:57 PM by kenjis.)

Remove all lines like "defined('BASEPATH') OR exit('No direct script access allowed');".

It is because PHPUnit died with the code.
Probably you know that exit() or die() terminates PHP execution.

OK found it. "defined('BASEPATH') or exit('No direct script access allowed');" was hiding in a file I kept around from when I was working with CI3. 
I have no idea how and why PHPUnit is processing that file. It is in a project folder but not included anywhere in the code. I guess I will need to look into that. This was strange.

Theme © iAndrew 2016 - Forum software by © MyBB