1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace JhFlexiTimeTest\Service; |
4
|
|
|
|
5
|
|
|
use JhFlexiTime\DateTime\DateTime; |
6
|
|
|
use JhFlexiTime\Entity\CappedCredit; |
7
|
|
|
use JhFlexiTime\Service\CappedCreditService; |
8
|
|
|
use JhUser\Entity\User; |
9
|
|
|
use PHPUnit_Framework_TestCase; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class CappedCreditServiceTest |
13
|
|
|
* @package JhFlexiTimeTest\Service |
14
|
|
|
* @author Aydin Hassan <[email protected]> |
15
|
|
|
*/ |
16
|
|
|
class CappedCreditServiceTest extends PHPUnit_Framework_TestCase |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var CappedCreditService |
20
|
|
|
*/ |
21
|
|
|
protected $service; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var \JhFlexiTime\Repository\CappedCreditRepositoryInterface |
25
|
|
|
*/ |
26
|
|
|
protected $repository; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var |
30
|
|
|
*/ |
31
|
|
|
protected $objectManager; |
32
|
|
|
|
33
|
|
|
public function setUp() |
34
|
|
|
{ |
35
|
|
|
$this->repository = $this->getMock('JhFlexiTime\Repository\CappedCreditRepositoryInterface'); |
36
|
|
|
$this->objectManager = $this->getMock('Doctrine\Common\Persistence\ObjectManager'); |
37
|
|
|
$this->service = new CappedCreditService($this->repository, $this->objectManager); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testCreate() |
41
|
|
|
{ |
42
|
|
|
$this->objectManager |
43
|
|
|
->expects($this->once()) |
44
|
|
|
->method('persist') |
45
|
|
|
->with($this->isInstanceOf('\JhFlexiTime\Entity\CappedCredit')); |
46
|
|
|
|
47
|
|
|
$this->objectManager |
48
|
|
|
->expects($this->once()) |
49
|
|
|
->method('flush'); |
50
|
|
|
|
51
|
|
|
$this->service->create(new User, 100, new DateTime('10 October 2014')); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function testSave() |
55
|
|
|
{ |
56
|
|
|
$this->objectManager |
57
|
|
|
->expects($this->once()) |
58
|
|
|
->method('persist') |
59
|
|
|
->with($this->isInstanceOf('\JhFlexiTime\Entity\CappedCredit')); |
60
|
|
|
|
61
|
|
|
$this->objectManager |
62
|
|
|
->expects($this->once()) |
63
|
|
|
->method('flush'); |
64
|
|
|
|
65
|
|
|
$capped = new CappedCredit; |
66
|
|
|
$capped->setDate(new DateTime('10 October 2014')); |
67
|
|
|
$capped->setUser(new User); |
68
|
|
|
$capped->setCappedCredit(100); |
69
|
|
|
|
70
|
|
|
$this->service->save($capped); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function testClearCappedCreditEntries() |
74
|
|
|
{ |
75
|
|
|
$user = new User; |
76
|
|
|
|
77
|
|
|
$this->repository |
|
|
|
|
78
|
|
|
->expects($this->once()) |
79
|
|
|
->method('deleteAllByUser') |
80
|
|
|
->with($user); |
81
|
|
|
|
82
|
|
|
$this->service->clearCappedCreditEntries($user); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.