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

Bug: The example of "The Test Class“ is not working in Documets #2993

Closed
isiungk opened this issue May 14, 2020 · 1 comment · Fixed by #2994
Closed

Bug: The example of "The Test Class“ is not working in Documets #2993

isiungk opened this issue May 14, 2020 · 1 comment · Fixed by #2994
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@isiungk
Copy link
Contributor

isiungk commented May 14, 2020

Direction
The example of "The Test Class“ is not working in Documets>Testing>Database>The Test Class.

Describe the bug
Following the CI4 documents, I created a test class as below:

<?php namespace App;

use CodeIgniter\Test\FeatureTestCase;

class MyAppTest extends FeatureTestCase
{
    public function setUp()
    {
        parent::setUp();
    }

    public function tearDown()
    {
        parent::tearDown();
    }
}

After run:

./phpunit ./tests/app/MyAppTest.php

I got:

PHP Fatal error:  Declaration of App\MyAppTest::setUp() must be compatible with CodeIgniter\Test\CIDatabaseTestCase::setUp(): void in ***/tests/app/MyAppTest.php on line 7

Afte learning the test demo in tests/unit/HealthTest.php, I modified the test class as below:

<?php namespace App;

use CodeIgniter\Test\FeatureTestCase;

class MyAppTest extends FeatureTestCase
{
    public function setUp(): void
    {
        parent::setUp();
    }

    public function tearDown(): void
    {
        parent::tearDown();
    }
}

and run './phpunit ./tests/app/MyAppTest.php' again, all comes OK.

I'm not sure if it's a bug, or the document is not up-to-date.

Rgds!

CodeIgniter 4 version
Which version (and branch, if applicable) the bug is in.
v4.0.3

Affected module(s)
Which package or class is the bug in, if known.
Maybe the documents, of "CodeIgniter\Test\FeatureTestCase" ? I'm not sure.

Expected behavior, and steps to reproduce if appropriate
None.

Context

  • OS: macOS Catalina
  • Web server: Apache/2.4.43 (Unix)
  • PHP version: PHP/7.4.5
@isiungk isiungk added the bug Verified issues on the current code behavior or pull requests that will fix them label May 14, 2020
@samsonasik
Copy link
Member

the doc need to be updated. Please provide PR

lonnieezell added a commit that referenced this issue May 14, 2020
Fix: Example code is not working #2993
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants