From apprentice to Artisan translation 02

Source: Internet
Author: User

Respect Boundaries Strict border

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.
Remember to maintain clear boundaries of responsibility. The controller and the route are used as middleware between HTTP and your application. When writing large applications, do not mix your domain logic (Controller, routing).

To solidify we 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:
In order to consolidate the knowledge learned, let's write a test case. First, we will simulate a database and then bind it to the IOC container of the application. We then make sure that the controller correctly calls the database:

Public Function Testindexactionbindsusersfromrepository () {        //Arrange ...    $repository = Mockery::mock (' userrepositoryinterface ');    $repository->shouldreceive (' All ')->once ()->andreturn (Array (' foo '));}

Asdasd

Class A

From apprentice to Artisan translation 02

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.