Giter Site home page Giter Site logo

Declaration of phpmock\phpunit\MockDisablerPHPUnit6::endTest(PHPUnit\Framework\Test $test, $time) must be compatible with PHPUnit\Framework\BaseTestListener::endTest(PHPUnit\Framework\Test $test, float $time): void in /home/vagrant/Code/boursify-app/vendor/php-mock/php-mock-phpunit/classes/MockDisablerPHPUnit6.php on line 50 about php-mock-phpunit HOT 2 CLOSED

php-mock avatar php-mock commented on June 14, 2024
Declaration of phpmock\phpunit\MockDisablerPHPUnit6::endTest(PHPUnit\Framework\Test $test, $time) must be compatible with PHPUnit\Framework\BaseTestListener::endTest(PHPUnit\Framework\Test $test, float $time): void in /home/vagrant/Code/boursify-app/vendor/php-mock/php-mock-phpunit/classes/MockDisablerPHPUnit6.php on line 50

from php-mock-phpunit.

Comments (2)

michalbundyra avatar michalbundyra commented on June 14, 2024

@francoislevesque Thanks for reporting, but I've just checked and I cannot reproduce the issue.

{
    "name": "michalbundyra/php-mock-test-phpunit-8",
    "require": {
        "php": "^7.2"
    },
    "require-dev": {
        "phpunit/phpunit": "8.5.3",
        "php-mock/php-mock-phpunit": "^2.3"
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "AppTest\\": "test/"
        }
    }
}

Result from composer show:

doctrine/instantiator              1.3.0   A small, lightweight utility to instantiate objects in PHP without invoking their constructors
myclabs/deep-copy                  1.9.5   Create deep copies (clones) of your objects
phar-io/manifest                   1.0.3   Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version                    2.0.1   Library for handling version information and constraints
php-mock/php-mock                  2.2.2   PHP-Mock can mock built-in PHP functions (e.g. time()). PHP-Mock relies on PHP's namespace fallback policy. No further extension is needed.
php-mock/php-mock-integration      2.1.0   Integration package for PHP-Mock
php-mock/php-mock-phpunit          2.6.0   Mock built-in PHP functions (e.g. time()) with PHPUnit. This package relies on PHP's namespace fallback policy. No further extension is needed.
phpdocumentor/reflection-common    2.1.0   Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/reflection-docblock  5.1.0   With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.
phpdocumentor/type-resolver        1.1.0   A PSR-5 based resolver of Class names, Types and Structural Element Names
phpspec/prophecy                   v1.10.3 Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage          7.0.10  Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator          2.0.2   FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-text-template          1.2.1   Simple template engine.
phpunit/php-timer                  2.1.2   Utility class for timing
phpunit/php-token-stream           3.1.1   Wrapper around PHP's tokenizer extension.
phpunit/phpunit                    8.5.3   The PHP Unit Testing framework.
sebastian/code-unit-reverse-lookup 1.0.1   Looks up which function or method a line of code belongs to
sebastian/comparator               3.0.2   Provides the functionality to compare PHP values for equality
sebastian/diff                     3.0.2   Diff implementation
sebastian/environment              4.2.3   Provides functionality to handle HHVM/PHP environments
sebastian/exporter                 3.1.2   Provides the functionality to export PHP variables for visualization
sebastian/global-state             3.0.0   Snapshotting of global state
sebastian/object-enumerator        3.0.3   Traverses array structures and object graphs to enumerate all referenced objects
sebastian/object-reflector         1.1.1   Allows reflection of object attributes, including inherited and non-public ones
sebastian/recursion-context        3.0.0   Provides functionality to recursively process PHP variables
sebastian/resource-operations      2.0.1   Provides a list of PHP built-in functions that operate on resources
sebastian/type                     1.1.3   Collection of value objects that represent the types of the PHP type system
sebastian/version                  2.0.1   Library that helps with managing the version number of Git-hosted PHP projects
symfony/polyfill-ctype             v1.17.0 Symfony polyfill for ctype functions
theseer/tokenizer                  1.1.3   A small library for converting tokenized PHP source code into XML and potentially other formats
webmozart/assert                   1.8.0   Assertions to validate method input/output with nice error messages.

Class in src/Example.php:

<?php

declare(strict_types=1);

namespace App;

class Example
{
    public function time() : int
    {
        return time();
    }
}

and test in test/ExampleTest.php:

<?php

declare(strict_types=1);

namespace AppTest;

use App\Example;
use phpmock\phpunit\PHPMock;
use PHPUnit\Framework\TestCase;

class ExampleTest extends TestCase
{
    use PHPMock;

    public function testTime() : void
    {
        $time = $this->getFunctionMock('App', 'time');
        $time->expects($this->once())->willReturn(3);

        $example = new Example();

        self::assertSame(3, $example->time());
    }
}

But first I've checked what class is loaded in vendor/php-mock/php-mock-phpunit/autoload.php:

if (! class_exists(\PHPUnit\Framework\BaseTestListener::class)) {
include __DIR__ . '/compatibility/BaseTestListener.php';
class_alias(
phpmock\phpunit\MockDisablerPHPUnit7::class,
phpmock\phpunit\MockDisabler::class
);
} else {
class_alias(
phpmock\phpunit\MockDisablerPHPUnit6::class,
phpmock\phpunit\MockDisabler::class
);
}

It looks like somehow you have class PHPUnit\Framework\BaseTestListener but it has been removed in PHPUnit 7 and there is no this class still in PHPUnit 8.

Can you check if you have this class somewhere? Thanks

from php-mock-phpunit.

francoislevesque avatar francoislevesque commented on June 14, 2024

Got it!

I installed xhgui on my VM which added PHPUnit\Framework\BaseTestListener here: /opt/xhgui/vendor/phpunit/phpunit/src/Framework/BaseTestListener.php

I simply removed xhgui, everything is working now! Thanks for the help 😁

from php-mock-phpunit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.