1 | <?php |
||
12 | class WebTranslateItFileServiceTest extends \PHPUnit_Framework_TestCase |
||
13 | { |
||
14 | /** |
||
15 | * @var WebTranslateItFileService |
||
16 | */ |
||
17 | private $service; |
||
18 | |||
19 | /** |
||
20 | * @var WebTranslateItRepository|\PHPUnit_Framework_MockObject_MockObject |
||
21 | */ |
||
22 | private $translationRepository; |
||
23 | |||
24 | /** |
||
25 | * Set up |
||
26 | */ |
||
27 | public function setUp() |
||
39 | |||
40 | /** |
||
41 | * Tear down |
||
42 | */ |
||
43 | public function tearDown() |
||
56 | |||
57 | /** |
||
58 | * Test should be updated with local file not present |
||
59 | */ |
||
60 | public function testShouldBeUpdatedWithNoLocalFile() |
||
69 | |||
70 | /** |
||
71 | * Test should be updated |
||
72 | * |
||
73 | * @dataProvider shouldBeUpdatedDataProvider |
||
74 | * |
||
75 | * @param string $localTimestamp |
||
76 | * @param string $remoteTimestamp |
||
77 | * @param string $localContent |
||
78 | * @param string $remoteContent |
||
79 | * @param bool $expectedResult |
||
80 | * @param string $message |
||
81 | */ |
||
82 | public function testShouldBeUpdated( |
||
83 | $localTimestamp, |
||
84 | $remoteTimestamp, |
||
85 | $localContent, |
||
86 | $remoteContent, |
||
87 | $expectedResult, |
||
88 | $message |
||
89 | ) { |
||
90 | $this->service->prepare($this->getTranslationDirectory()); |
||
91 | $filePath = sprintf('%s/%s', $this->getTranslationDirectory(), $this->getProjectFileDTO()->getName()); |
||
92 | file_put_contents($filePath, $localContent); |
||
93 | touch($filePath, (new \DateTime($localTimestamp))->getTimestamp()); |
||
94 | |||
95 | $projectFile = new ProjectFileDTO(); |
||
96 | $projectFile |
||
97 | ->setUpdatedAt(new \DateTime($remoteTimestamp)) |
||
98 | ->setHashFile(sha1($remoteContent)) |
||
99 | ; |
||
100 | |||
101 | $this->assertEquals($expectedResult, $this->service->shouldBeUpdated($filePath, $projectFile), $message); |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * @return array |
||
106 | */ |
||
107 | public function shouldBeUpdatedDataProvider() |
||
116 | |||
117 | /** |
||
118 | * Test update |
||
119 | */ |
||
120 | public function testUpdate() |
||
131 | |||
132 | /** |
||
133 | * Test prepare |
||
134 | */ |
||
135 | public function testPrepare() |
||
140 | |||
141 | /** |
||
142 | * @return string |
||
143 | */ |
||
144 | private function getTranslationDirectory() |
||
148 | |||
149 | /** |
||
150 | * @return string |
||
151 | */ |
||
152 | private function getPullFileContent() |
||
156 | |||
157 | /** |
||
158 | * @return ProjectFileDTO |
||
159 | */ |
||
160 | private function getProjectFileDTO() |
||
169 | } |
||
170 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: