Comments (2)
@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
:
Lines 70 to 81 in 308a7aa
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.
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)
- phpmock\phpunit\PHPMock not installing HOT 5
- PHPUnit 7 support HOT 3
- Searching new maintainer
- Compatibility with PHPUnit 7.4 HOT 5
- Not work if mocked in test method and tests was run from phpunit command HOT 1
- Add PHPUnit 8 support HOT 1
- Add PHPUnit 8.1 compatibility HOT 2
- Error: Call to undefined method phpmock\phpunit\MockObjectProxyNoReturnTypes::will() HOT 1
- Incompatibility with PHPUnit 8.4 HOT 2
- 'parameters' is private member, use getParameters() instead.
- Declaration of Codeception\Test\Test::toString() must be compatible with PHPUnit\Framework\SelfDescribing::toString(): HOT 3
- phpunit 8.3: cannot implement PHPUnit\Framework\MockObject\Rule\InvocationOrder HOT 2
- phpspec/prophecy is now explicitely needed for tests HOT 1
- Incompatible declaration of MockDisablerPHPUnit6::endTest HOT 1
- InvocationOrder - it is not an interface HOT 1
- Support PHPUnit 10 HOT 2
- Mocking time function in one test method affects the other
- Incompatible with PHPUnit >= 10.3 HOT 7
- [QUESTION] - Deprecated Methods in phpunit 11 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-mock-phpunit.