Skip to content

HTML Code coverage showing comments as uncovered lines of code #101

@josefvn

Description

@josefvn

Please refer to stackoverflow.com post:

http://stackoverflow.com/questions/11008812/phpunit-coverage-report-showing-non-code-line-as-not-covered

I've got a class defined as follows:

class User implements UserInterface, \Serializable
{
    ...
        /**
     * Serialize user object and return as a string.
     *
     * @return string
     */
    public function serialize()
    {
        return serialize(array(
            'id' => $this->id,
            'username' => $this->username
        ));
    }

    /**
     * Deserialize from the given $data string.
     *
     * @param string $data
     *
     * @return mixed|void
     */
    public function unserialize($data)
    {
        $data = unserialize($data);
        $this->id = $data['id'];
        $this->username = $data['username'];
        return $this;
    }
    ...
}

When I run my unit tests, they pass 100%, but when looking at my code coverage report, I see the following:

Screenshot

Basically the line where I have @return mixed|void is marked as uncovered code, and it's affecting the code coverage statistics.

The only way to make the error go away, is by either removing either UserInterface, or \Serializable from the implements clause, so this seems to be a problem where a class implements multiple interfaces. When I do this, my class is covered 100%, but with the defect, it is marked as 89.06% covered?

I am using

  • PHP Version 5.3.8
  • XDebug version v2.2.0-dev
  • PHPUnit 3.6.11 by Sebastian Bergmann.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions