Comments (10)
Well I've considered (not very thoroughly) some options:
- Non-static helper
- Change Console to be a normal class that takes the streams as constructor argument
- Add
Console::__callStatic
to support static calls that default to a singleton instance.
(I think this is similiar to Laravel Facades)
- Static configuration of streams
- Add
public static $stdout = \STDOUT;
which is overridable.
- Switch to
echo
(but this does not solve the issue forSTDERR
).
from yii-console.
Do you have an idea on how to fix it?
from yii-console.
Or more advanced, haven't tested this myself: https://stackoverflow.com/questions/8348927/is-there-a-way-test-stderr-output-in-phpunit
from yii-console.
What's about $I->seeInShellOutput()
from Codeception?
Examples: https://github.com/dmstr/phd5-app/blob/master/tests/codeception/cli/1-YiiCept.php
from yii-console.
It doesn't work since it can't intercept fwrite
commands.
from yii-console.
Hmm, I am testing all the output written by $this->stdout()
this way?!
from yii-console.
Ah wait you're running new shell commands instead of running the test inside the same process.
Basically the approach you use is not about Yii
at all, your tests could test any executable by executing it and checking the result.
That is not the same as testing one specific function; it would work though...
from yii-console.
@SamMousa Ah yes, you are right. I never got familiar with mocking all the stuff :) But, I remember having issues with STDERR also.
from yii-console.
@SamMousa Did you consider "mocking" fwrite
in tests, like so https://www.schmengler-se.de/en/2011/03/php-mocking-built-in-functions-like-time-in-unit-tests/
from yii-console.
How about mock/DI replace Console class for tests?
from yii-console.
Related Issues (20)
- On not instantiable command class show exception about this instead of "The command does not exist." HOT 1
- Show error trace on throw error HOT 1
- Aliased commands can not be executed
- After update happened error HOT 2
- Implement autocompletion
- ./yii serve not works in windows PHP 8.0, PHP 8.1. HOT 3
- Add docs for `./yii serve` command
- Raise PHP version to 8.0
- Add support `symfony/event-dispatcher-contracts` version `^3.0` HOT 1
- Default options for ./yii serve must be configurable
- Add test for `ApplicationStartup` with and without command name in constructor
- "list <namespace>" command does not work HOT 1
- Shortcuts do not work HOT 2
- ./yii serve not work for windows
- Rename `params.php` to `params-console.php`
- Add ability to autoregistration commands from specified directory or namespace
- Make logger in `ErrorListener` required, and remove event from package configuration
- update irc link
- update src folder links
- update root folder links
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 yii-console.