【问题标题】:codeception db module errorcodeception db模块错误
【发布时间】:2015-03-30 00:37:55
【问题描述】:

我正在尝试在 codeception 中创建一个功能测试,在这里我可以检查数据库表是否被 pupulated 这里是测试:

<?php 
 $I = new FunctionalTester($scenario);
 $I->am('A guest');
 $I->wantTo('Sign up for an account');

 $I->amOnPage('auth/register');
 $I->fillField('username', 'testuser');
 $I->fillField('first_name', 'test_name');
 $I->fillField('last_name', 'test_last');
 $I->fillField('email', 'test@test.com');
 $I->fillField('password', 'test');
 $I->click('Sign up!');

 $I->seeInDatabase('users', ['username' => 'testuser', 'first_name' => 'test_name', 'last_name' => 'test_last', 'email' => 'test@test.com', 'slug' => 'testuser']);

这里是yaml文件:

class_name: FunctionalTester
modules:
    enabled: [Filesystem, FunctionalHelper, Db, PhpBrowser]
    config:
      Db:
         dsn: 'mysql:host=localhost;dbname='db''
         user: 'root'
         password: 'pass!'
         dump: 'tests/_data/dump.sql'
         populate: true
         cleanup: false
      PhpBrowser:
        url: 'http://localhost:8000'

我得到了错误:

   Couldn't see in database "users",    {"username":"testuser","first_name":"test_name","last_name":"test_last","email":"test@test.com","slug":"testuser"}:
No matching records found
Failed asserting that '0' is greater than 0.

但是,当我在浏览器中填写表单时,代码有效并且用户已注册

【问题讨论】:

    标签: php laravel tdd codeception


    【解决方案1】:

    你应该尝试使用Laravel4/Laravel5(你没有提到Laravel版本)模块,然后使用seeRecord方法。我对 grabFromDatabase 有完全相同的问题 - 它不起作用但是当我使用 Laravel 模块中的 grabRecord 时它工作正常。

    【讨论】:

      猜你喜欢
      • 2016-08-28
      • 2021-11-19
      • 2017-02-28
      • 2018-10-16
      • 2019-05-20
      • 2016-07-19
      • 1970-01-01
      • 2013-09-17
      • 2013-09-09
      相关资源
      最近更新 更多