File tree 1 file changed +6
-3
lines changed
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::
48
48
49
49
public function calculateTotalSalary($id)
50
50
{
51
- $employeeRepository = $this->entityManager->getRepository('AppBundle::Employee');
51
+ $employeeRepository = $this->entityManager
52
+ ->getRepository('AppBundle::Employee');
52
53
$employee = $employeeRepository->find($id);
53
54
54
55
return $employee->getSalary() + $employee->getBonus();
@@ -74,15 +75,17 @@ it's easy to pass a mock object within a test::
74
75
->will($this->returnValue(1100));
75
76
76
77
// 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')
78
80
->disableOriginalConstructor()
79
81
->getMock();
80
82
$employeeRepository->expects($this->once())
81
83
->method('find')
82
84
->will($this->returnValue($employee));
83
85
84
86
// 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')
86
89
->disableOriginalConstructor()
87
90
->getMock();
88
91
$entityManager->expects($this->once())
You can’t perform that action at this time.
0 commit comments