File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,8 @@ Suppose the class you want to test looks like this::
4848
4949 public function calculateTotalSalary($id)
5050 {
51- $employeeRepository = $this->entityManager->getRepository('AppBundle::Employee');
51+ $employeeRepository = $this->entityManager
52+ ->getRepository('AppBundle::Employee');
5253 $employee = $employeeRepository->find($id);
5354
5455 return $employee->getSalary() + $employee->getBonus();
@@ -74,15 +75,17 @@ it's easy to pass a mock object within a test::
7475 ->will($this->returnValue(1100));
7576
7677 // Now, mock the repository so it returns the mock of the employee
77- $employeeRepository = $this->getMockBuilder('\Doctrine\ORM\EntityRepository')
78+ $employeeRepository = $this
79+ ->getMockBuilder('\Doctrine\ORM\EntityRepository')
7880 ->disableOriginalConstructor()
7981 ->getMock();
8082 $employeeRepository->expects($this->once())
8183 ->method('find')
8284 ->will($this->returnValue($employee));
8385
8486 // Last, mock the EntityManager to return the mock of the repository
85- $entityManager = $this->getMockBuilder('\Doctrine\Common\Persistence\ObjectManager')
87+ $entityManager = $this
88+ ->getMockBuilder('\Doctrine\Common\Persistence\ObjectManager')
8689 ->disableOriginalConstructor()
8790 ->getMock();
8891 $entityManager->expects($this->once())
You can’t perform that action at this time.
0 commit comments