Comments (7)
It seems that you want to test your pluging using some values that are stored in a cookie.
I dont think that you can use cookies in PHPUnit but i am not 100% sure about this, cause PHPUnit use cli command and not http.
You can add a setter method to your plugin where you pass cookies values and use this method in your tests.
from yaf.
Yes, but the solution would be a method which would allow me to fake headers for request by overwriting them. In such a case I wouldn't need real cookies support.
Adding setter method in a plugin also it's not a good solution because the code depends on cookies from Yaf_Request, in real app I won't be able to preset these cookies.
from yaf.
I see, so in your plugin you use for example $request->getCookies()
method.And you want somehow to set some cookies to the Request object for testing right?
Then i think it is better to create a mock subclass of Yaf_Request as you mention in your first post and create setCookies()
and getCookies()
methods in this class.
from yaf.
For now it's done this way. I was wondering if there's better way to do this. It looks like it's currently the only possibility.
from yaf.
I think that you use the best way. Mocking classes are common in unit tests and allow flexible testing.
Besides there is no reason to add a setCookies()
method in the core Request object, cause Request object should have headers for read only purpose. setCookies()
method should have meaning if it was in Response object.
from yaf.
:)
from yaf.
Ok, I will leave it then this way. Thank you for the response (and sorry for making here the thread but I didn't found any other place where I would be able to ask a question about Yaf).
from yaf.
Related Issues (20)
- Request::setControllerName 第二个参数format==false时 设置失败 HOT 1
- Yaf_Registry::set 的第二个参数为什么注释为 string 类型 HOT 1
- yaf model 的问题 HOT 2
- 开启公用类库后,无法使用composer HOT 2
- 偶发性问题Uncaught Error: Call to a member function run() on bool in ....../public/index.php HOT 1
- 希望鸟哥能增加一个配置用于控制是否开启默认路由. HOT 1
- yaf routing with namespace is on option HOT 4
- Fatal error: Class 'Yaf' not found HOT 2
- PHP8.2下 安装yaf-3.3.5报错 HOT 5
- Yaf_Config_Ini 造成 Too many open files 问题 HOT 3
- 使用了__get魔术方法后,当action不存在的时候,php进程会被直接终止,无法捕获错误。 HOT 4
- 支持phpstorm的代码查找
- v3.3.5 Yaf_View_Simple __isset bug
- fpm进程中存在多个application.ini文件句柄 HOT 3
- Error: Failed opening controller script
- PHP8.3 install yaf-3.3.5、yaf-3.3.4 extenstion error:make: *** [Makefile:209: yaf.lo] Error 1 HOT 2
- README.md contains outdated references to Travis CI service
- php-ext
- 使用 Yaf_Request_Http 对象的 getRequest(), getPost(), getQuery() 3个方法获取单个参数时候会导致程序中断
- 能否写个php 多线程处理的扩展啊。现在并发需求多。用户访问量大。
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 yaf.