Comments (4)
Is it actually expected behavior?
Well, as you can see, PHP prefixes error messages with the "callable context" for throwed TypeError, so "Kahlan\Cli\Kahlan::{closure}():" is something added by PHP itself.
<?php
namespace Simple\Test;
use DateTime;
use Throwable;
function test(DateTime $datetime) {}
try {
test(null);
} catch (Throwable $e) {
echo $e->getMessage(); // Simple\Test\test(): Argument #1 ($datetime) must be of type DateTime, null given, called in [...][...] on line 11
}
I'd expect the test should give me something like this if the test was failed.
Indeed, I fixed it in the 5.1.1 release.
from kahlan.
When you define a specific error message to an Exception it must matches the throwed one.
What make you feel there's an issue here ?
from kahlan.
it must matches the throwed one
@jails exactly! but, as we can see the error message was
message:`TypeError` Code(0) with message "Kahlan\\Cli\\Kahlan::{closure}(): ...."
It seems like it was thrown from a closure inside Kahlan\Cli\Kahlan
namespace instead of the test file, which doesn't have namespace.
Is it actually expected behavior?
from kahlan.
Also the failed message
doesn't show the complete error message, or I could say it less informative.
actual:
(object) an instance of `TypeError`
expected:
(object) an instance of `TypeError`
To me, it sounds like "Hey, go have a test failed. You expecting an instance of TypeError, but you got an instance of TypeError". What's make it failed?
I hope it could be more informative, or at least it should behave like any other tests using toThrow()
. e.g. I have a test as follow
expect(function () {
// ...
})->toThrow(new SomeException('Some expected message'));
I'd expect the test should give me something like this if the test was failed.
It expect actual to throw a compatible exception.
actual:
(object) an instance of `SomeException` Code(0) with message "Some actual message"
expected:
(object) an instance of `SomeException` Code(0) with message "Some expected message"
So I can easily understand what's missing and what's makes my test failed,
from kahlan.
Related Issues (20)
- Throw exception test failed with Pipeline CI/CD HOT 2
- How to mock ZipArchive behavior HOT 4
- Error with PHP 8 HOT 1
- Unable to run the tests when `XDEBUG_MODE` have multiple values HOT 1
- Feature Request: Support focusing a specific test or suite with command line arguments
- php 8.1 support HOT 2
- PHP Fatal error: Type of Kahlan\PhpErrorException::$file must be string (as in class Exception) in... HOT 3
- toBeCalled within Class Static Methods HOT 1
- Breakpoint; debugging tests HOT 4
- Missing default value 0 for int properties with PHP8 attributes in single line HOT 1
- Unable to stub without overriding function HOT 5
- Process exit with code 1 in github action HOT 2
- stub / Modify constante HOT 1
- PHP 8.2: dynamic properties HOT 3
- PHP 8.2 Function utf8_decode() is deprecated HOT 1
- Support for never return type (PHP 8.1+) HOT 5
- Cannot exclude autoloaded files from monkey patching
- Multiple _T_ATTRIBUTE tokens in single line HOT 1
- Bug: toHaveLength() does not work with accented letters and multi-byte strings HOT 1
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 kahlan.