douzhuan1432 2015-11-09 11:50
浏览 56
已采纳

Codeception不会回滚Laravel 5中的DB更改吗?

I am new to codeception and I am using it to test a web service I am creating in laravel 5. So my main config file looks like so:

codeception.yml

actor: Tester
paths:
    tests: tests
    log: tests/_output
    data: tests/_data
    support: tests/_support
    envs: tests/_envs
settings:
    bootstrap: _bootstrap.php
    colors: true
    memory_limit: 1024M
extensions:
    enabled:
        - Codeception\Extension\RunFailed
modules:
    config:
        Db:
            dsn: 'mysql:host=localhost;dbname=carparts'
            user: 'root'
            password: 'SomePassword'
            dump: tests/_data/dump.sql

And the suite file called api.suite.yml looks like so:

class_name: ApiTester
modules:
    enabled:
        - Laravel5
        - REST:
            url: http://localhost:8000/api/
            depends: PhpBrowser
    config:
        Laravel5:
            cleanup: true
            environment_file: .env.testing

I also copy pasted the whole dump of my database carparts into the dump.sql file but still when I run the tests, I still see new users created which are being created in the tests. What am I missing? Where am I going wrong?

  • 写回答

1条回答 默认 最新

  • dpb42021 2015-11-12 09:12
    关注

    So I did not know that in order to rollback the DB I need to enable the Db module:

    class_name: ApiTester
    modules:
        enabled:
            - Laravel5
            - Db
            - REST:
                url: http://localhost:8000/api/
                depends: PhpBrowser
        config:
            Laravel5:
                cleanup: true
                environment_file: .env.testing
    

    And that did it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?