Skip to content

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

Description

@isiungk

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions