dtwupu6414 2012-07-17 22:36
浏览 174

使用PHPUnit在PHP中测试REST API控制器

I have a very small test suite for testing CRUD operations on a REST API. My controller displays a form, table, etc, based on the information provided by the API. My test class create a new Buzz object and makes requests to the API server.

Unfortunately, this sucks, because if i update or delete something, it is deleted in the API. This is a very bad test practice. How can i unit test my application, when using an external data source like this?

  • 写回答

2条回答 默认 最新

  • dpcnm2132 2012-07-17 22:40
    关注

    Look into test doubles and stubs in the PHPUnit docs:

    http://www.phpunit.de/manual/current/en/test-doubles.html

    You can use them to replace API functionality.

    评论

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退