问题标签 [phpspec]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
symfony - PHPSpec symfony2 表单类型
我想测试 Symfony2 的表单类型。我有一个自定义表单类型,我的测试如下所示:
我得到: 致命错误:在非对象上调用成员函数 add() 在 buildForm 方法中我从 FormBuilderInterface 调用 $this->add 方法我该如何解决这个问题?
php - 具有多个套件的 PHPSpec 只考虑最后一个
我正在尝试将 PHPSpec 与多个套件一起使用。
这是必需的,因为我的应用程序有几个不需要计算命名空间的路径(它是一个 Code Igniter 应用程序)。
我设置了phpspec.yml
这样的:
每当我运行./bin/phpspec describe Foo
它时,它都会在spec/my_app/models/FooSpec
.
之后,即使我将它(包括命名空间)移动到libraries
文件夹,当 phpspec 尝试创建新的类文件或新方法(仍然不存在)时,它也会尝试在../sistemas/my_app/application/models/
.
有没有办法告诉phpspec每个类将使用哪个套件?
php - PhpSpec 测试捕获异常
我有一个简单的测试:
这是我要测试的代码:
已经测试过的错误处理程序类将返回一个扩展“Acme\Exception\ErrorResponseException”的类。问题是,如何从 guzzle 客户端模拟返回的异常?
我尝试使用预言的 willTrhow 和 ThrowPromises https://github.com/phpspec/prophecy
我的错误是什么?
我的意思是,使用以下代码:
'runCommand' (测试的函数)它将返回 BadResponseException 但它没有被我的代码捕获。
php - 如何测试包括(PHPUnit / PHPSpec / SimpleTest / 等)
假设我有以下课程:
假设 $file 包含以下内容:
如何测试它?具体来说,您如何为“包含”创建双精度。
php - phpspec - 方法返回对象而不是字符串
我对 phpspec 还很陌生,但通常我会在遇到问题时找到解决方案,但这很难。
我尝试了许多不同的方法,但没有找到解决方案。我正在使用 Symfony2。
我有一个要测试的课程:
这是我的规范类的外观:
运行 phpspec 后,我收到此错误:
我不知道如何解决这个问题。如果有人有线索,请帮助。
php - phpspec - 获取返回值
我想获得对象的实际返回值而不是可链接的对象。
有没有办法让这种情况发生?
谢谢。
php - PHPSpec: Issue stubbing out PDO::execute
I'm having an issue stubbing out PDO::execute using PHPSpec and prophecy, but I keep getting an error that:
Here's my spec:
I know Prophecy doesn't stub out any methods that don't exist, but PDO is baked into PHP and the PDO::prepare stub works fine. Thanks for any help you can give.
php - 如何在 phpspec 测试中使用 laravel 会话
我正在尝试使用 phpspec 测试一个非常简单的类。
应该测试的类的一些方法
和一份试卷
不幸的是,测试失败并it_stores_an_orderId
出现此错误expected "testvalue", but got null.
当这些方法setCurrentOrderId
和getCurrentOrderId
用于工匠的修补匠时,它们工作得很好。
似乎在我的测试环境中,会话设置有问题。
如何解决这个问题?
php - PhpSpec return always null on mocks
I'm working with PhpSpec and for some reason when I mock my dependencies and call them the willReturn
method of PhpSpec give me a null
value instead of the value passed.
This is the method that I'm trying to describe
My Spec
I'm stuck with this issue, any suggest will be appreciated.
php - 在派生类中模拟数据库
我有实现特定接口并为特定数据库扩展基类的存储库类。
基类:
派生类:
规格:
运行 PHPSpec 时,我得到:property db not found
除了将属性设置为之外,还有其他方法可以解决此问题public
吗?
将其设置为后,public
我得到:call to a member function willReturn() on a non-object.
所以我无法继续->willReturn()
运行$this->db
但为什么?在测试方法中执行此操作时let
,它可以工作。但并非所有测试都需要返回相同的数据......
我如何让它运行?