- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 Yii2 中使用 Codeception 进行验收测试,但无法访问我的模型,因为命名空间不适用于这些测试。
我在我的测试/_bootstrap.php 中有这个
require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
$config = require(__DIR__ . '/../console/config/main.php');
//
$application = new yii\console\Application( $config );
## Added (@vitalik_74)
Yii::setAlias('@tests', dirname(__DIR__));
<?php
$params = array_merge(
require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php')
);
return [
'id' => 'app-console',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'controllerNamespace' => 'console\controllers',
'components' => [
'log' => [
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
],
'params' => $params,
];
<?php
return [
'adminEmail' => 'admin@example.com',
'supportEmail' => 'support@example.com',
'user.passwordResetTokenExpire' => 3600,
];
<?php namespace tests\acceptance;
use \AcceptanceTester;
use backend\models\User; ## I have tried writing it with a / at the beggining
class ListUserCest
{
public function _before(AcceptanceTester $I)
{
}
public function _after(AcceptanceTester $I)
{
}
public function init(AcceptanceTester $I)
{
$this->login($I);
if( User::find()->exists() )
$I->amGoingTo('List Users having at least one');
else
$I->amGoingTo('List Users having any');
}
...
PHP Fatal error: Class 'backend\models\User' not found in /var/www/project/tests/acceptance/ListUserCest.php on line 21 Error: Class 'backend\models\User' not found
<?php
namespace backend\models;
use common\helpers\MathHelper;
use backend\models\AntropometricData;
use Yii;
class User extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'user';
}
...
最佳答案
将下一个代码放到 tests/_bootstrap.php 中:
require('vendor/autoload.php');
require('vendor/yiisoft/yii2/Yii.php');
$config = require('config/web.php');
(new yii\web\Application($config));
关于命名空间不适用于 Codeception (Yii2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29681347/
我的表单包含一个隐藏字段 csrf 并且我的 Controller 有一个方法来检查 CSRF 攻击。在我的功能测试中,我尝试通过fillField 来检查我的Controller 的方法 如果有人t
我正在 docker 容器中进行 Codeception 验收测试。我可以运行整个项目,但不能运行单个测试或类。是否有任何配置选项或参数来解决这个问题? 这有效(运行所有测试): codecept -
我正在使用 Codeception 运行验收测试,我需要计算带有“.remove”类的按钮在一页中出现的次数。此类按钮位于 html 表内,计数取决于购物车中的商品数量。 下面是我尝试使用的代码:
就像我们在 codecetion 中从命令提示符传递浏览器名称和其他详细信息一样,我们可以从命令提示符传递可以在脚本中使用的任何变量吗? 最佳答案 我没有在文档和其他提要中找到任何方法。 我为此能力添
在 PHP Codeception test framework ,我希望能够一次运行多个套件。 我可以像这样运行它们: codecept run 或者我可以像这样运行单个套件: codecept r
我正在使用 codeception,当我尝试检查 dbconnection 时它显示错误: > DEPRECATION: Calling the > "Symfony\Component\EventD
$I->fillField("username", "test"); 在运行验收测试时,收到以下错误: 抱歉,我无法填写字段“用户名”、“测试”: ErrorException: DOMXPath::
我有 API 端点: [GET] /car/:carId 这实际上是一个 Controller Action (CarController::car( $carId ) ): public funct
我有一个 PHP 应用程序,我们正在使用 Codeception 添加测试。我们尝试将 Specify(和 Verify)添加到我们的套件中,但未被识别。您如何正确设置 Specify 以与 Code
我正在尝试为使用 Codeception 的 Paypal Express Checkout 付款编写验收测试。问题是上下文窗口。当我没有窗口名称时,如何切换到那个窗口来填写字段?感谢您的帮助。 最佳
我正在编写一个测试,但它没有像我预期的那样工作。 我需要使用一些抓取器,然后在测试运行时转储到屏幕上。 我该怎么做?如何回显,而不是用户抓取器如何;我可以使用抓取器,但我不知道如何在测试运行时回显。
-- Select an Option -- @foreach ($options as $option) value }}'>{{ $option->name }}
刚开始使用 codeception 2.0.9 并安装了 phantomjs 并运行了一些示例测试。 Codeception 在最后给出了一个简洁的 html 报告,用红色和绿色总结了通过的测试,这很
我正在使用 Codeception 运行验收测试,我需要计算带有“.remove”类的按钮在一页中出现了多少次。此类按钮位于 html 表格内,计数取决于购物车中的商品数量。 以下是我尝试使用的代码:
使用 Codeception 测试框架和 Selenium 2 模块来测试一个网站,我最终点击了一个超链接,该超链接打开了一个没有名称的新窗口。结果, switchToWindow() 函数将无法工作
亲爱的 Stackoverflow 用户,您好 目前我正在使用 Selenium 作为 WebDriver 模块使用 Codeception 编写验收测试。在我检查我们的子导航是否存在、是否完整并且有
我在 Yii2 中使用 Codeception 进行验收测试,但无法访问我的模型,因为命名空间不适用于这些测试。 我在我的测试/_bootstrap.php 中有这个 require(__DIR__
我一直在使用 Codeception 编写一些单元测试,并且我的数据库已被测试数据过度运行。在阅读文档时,我发现它说: Database will be cleaned and populated a
有没有办法断言某个元素(例如输入或链接)具有键盘焦点?我正在将 Codeception 与 Selenium 结合使用。在 http://codeception.com/docs/modules/We
我无法通过代码接收复制 ajax 调用。 例如: $I->sendAjaxPostRequest('login/verify', array('name' => 'name', 'password'
我是一名优秀的程序员,十分优秀!