introduction repository, ddd and unit test
TRANSCRIPT
IntroductionRepository, DDD & Unit Tests
Agenda
- Repository- DDD- Unit Test
Case Study : Working on Laravel 5.0
Stories
- I want to test the data logic but i dont care the data engine (database)
- I want to test the data engine (database) but i dont care the data logic
automated tests...
In Reality
Problem?
“ the power of united data logic and database, called ORM “
Real problem?
As programmer we have to make sure every single unit should be working properly..
the keyword is -> every single unit of our code
Repository
Benefit?
- We can test logic without engine- We can test engine without logic- We can test the repository it self
easy to mocking…separation of concerns...
DDD
Solve complex needs by modelling the domain
DDD Things
- Entity. Unique object- ValueObject. Immutable object
Example
Users data that contain their credentials like email, username and password.
In DDD:User is an entity, password can be a ValueObject.
Unit Test
1 class 1 responsibility
We should can test each of 1 class without thinking the dependency complexity (replace all dependency with mock)
Enough!
SHOW ME THE CODES!