码迷,mamicode.com
首页 > 移动开发 > 详细

From Apprentice To Artisan 翻译 02

时间:2014-08-22 14:39:39      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:http   os   io   ar   art   cti   log   sp   on   

Respect Boundaries 严守边界

Remember to respect responsibility boundaries. Controllers and routes serve as a mediator between HTTP and your application. When writing large applications, don‘t clutter them up with your domain logic.
记得要保持清晰的责任边界。 控制器和路由是作为HTTP和你的应用程序之间的中间件来用的。当编写大型应用程序时,不要将你的领域逻辑混杂在其中(控制器、路由)。

To solidify our understanding, let‘s write a quick test. First, we‘ll mock the repository and bind it to the application IoC container. Then, we‘ll ensure that the controller properly calls the repository:
为了巩固学到的知识,咱们来写一个测试案例。首先,我们要模拟一个资料库然后绑定到应用的IoC容器里。 然后,我们要保证控制器正确的调用了这个资料库:

public function testIndexActionBindsUsersFromRepository()
{    
    // Arrange...
    $repository = Mockery::mock(‘UserRepositoryInterface‘);
    $repository->shouldReceive(‘all‘)->once()->andReturn(array(‘foo‘));
}

asdasd

class a

From Apprentice To Artisan 翻译 02

标签:http   os   io   ar   art   cti   log   sp   on   

原文地址:http://my.oschina.net/zgldh/blog/305556

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!