首页 > 代码库 > From Apprentice To Artisan 翻译 02
From Apprentice To Artisan 翻译 02
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。