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

issue during code coverage when referencing $this->uri in a view #412

Open
tenzap opened this issue Feb 13, 2024 · 5 comments
Open

issue during code coverage when referencing $this->uri in a view #412

tenzap opened this issue Feb 13, 2024 · 5 comments

Comments

@tenzap
Copy link

tenzap commented Feb 13, 2024

While running codecoverage, there is a failure on this line of a *.php file in applications/view/

Line on which it fails:

<?php if ( ! empty($this->uri->segment(1))

Command: vendor/bin/phpunit --coverage-text -c application/tests

Output:

PHPUnit 9.6.16 by Sebastian Bergmann and contributors.
Generating code coverage report in Clover XML format ... <script language="javascript">
...

Undefined property: SebastianBergmann\CodeCoverage\CodeCoverage::$uri

There is no such issue with ci-phpunit-test 2.x or 1.x.

package versions installed by composer.

  - Installing codeigniter/framework (3.1.13): Extracting archive
  - Installing datto/json-rpc (6.1.0): Extracting archive
  - Installing datto/json-rpc-http (5.0.6): Extracting archive
  - Installing econea/nusoap (v0.9.16): Extracting archive
  - Installing symfony/polyfill-mbstring (v1.29.0): Extracting archive
  - Installing giggsey/locale (2.5): Extracting archive
  - Installing giggsey/libphonenumber-for-php (8.13.30): Extracting archive
  - Installing nikic/php-parser (v4.18.0): Extracting archive
  - Installing kenjis/ci-phpunit-test (v3.0.4): Extracting archive
  - Installing kissifrot/php-ixr (1.8.4): Extracting archive
  - Installing league/csv (9.7.4): Extracting archive
  - Installing paragonie/random_compat (v9.99.100): Extracting archive
  - Installing sebastian/version (3.0.2): Extracting archive
  - Installing sebastian/type (3.2.1): Extracting archive
  - Installing sebastian/resource-operations (3.0.3): Extracting archive
  - Installing sebastian/recursion-context (4.0.5): Extracting archive
  - Installing sebastian/object-reflector (2.0.4): Extracting archive
  - Installing sebastian/object-enumerator (4.0.4): Extracting archive
  - Installing sebastian/global-state (5.0.6): Extracting archive
  - Installing sebastian/exporter (4.0.5): Extracting archive
  - Installing sebastian/environment (5.1.5): Extracting archive
  - Installing sebastian/diff (4.0.5): Extracting archive
  - Installing sebastian/comparator (4.0.8): Extracting archive
  - Installing sebastian/code-unit (1.0.8): Extracting archive
  - Installing sebastian/cli-parser (1.0.1): Extracting archive
  - Installing phpunit/php-timer (5.0.3): Extracting archive
  - Installing phpunit/php-text-template (2.0.4): Extracting archive
  - Installing phpunit/php-invoker (3.1.1): Extracting archive
  - Installing phpunit/php-file-iterator (3.0.6): Extracting archive
  - Installing theseer/tokenizer (1.2.2): Extracting archive
  - Installing sebastian/lines-of-code (1.0.4): Extracting archive
  - Installing sebastian/complexity (2.0.3): Extracting archive
  - Installing sebastian/code-unit-reverse-lookup (2.0.3): Extracting archive
  - Installing phpunit/php-code-coverage (9.2.30): Extracting archive
  - Installing phar-io/version (3.2.1): Extracting archive
  - Installing phar-io/manifest (2.0.3): Extracting archive
  - Installing myclabs/deep-copy (1.11.1): Extracting archive
  - Installing doctrine/instantiator (1.5.0): Extracting archive
  - Installing phpunit/phpunit (9.6.16): Extracting archive
@kenjis
Copy link
Owner

kenjis commented Feb 13, 2024

I believe this is a PHPUnit specification.

@tenzap
Copy link
Author

tenzap commented Feb 13, 2024

$this->uri is part of CI. I haven't found any reference to a variable named uri in phpunit.

@kenjis
Copy link
Owner

kenjis commented Feb 13, 2024

No, no. The $this->uri is interpreted as SebastianBergmann\CodeCoverage\CodeCoverage::$uri.
That is, $this is SebastianBergmann\CodeCoverage\CodeCoverage at that time.

@tenzap
Copy link
Author

tenzap commented Feb 13, 2024

I'm not sure I understand. Anyway it doesn't fail with earlier versions of your tool and afaik it is totally valid to use $this->some_var_from_controller inside a PHP file of the application/view.

https://codeigniter.com/userguide3/libraries/uri.html

@kenjis
Copy link
Owner

kenjis commented Feb 13, 2024

Are you using the same version of PHPUnit?
Perhaps the behavior of PHPUnit CodeCoverage has changed.

Anyway, ci-phpunit-test does nothing to PHPUnit CodeCoverage.
So I cannot do anything to it.

If you think it is a bug, please report to PHPUnit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants