Skip to content

Commit fa93f75

Browse files
committed
Merge remote-tracking branch 'origin/master' into 0.14
2 parents 76fbfe8 + 7f898f9 commit fa93f75

File tree

2 files changed

+66
-48
lines changed

2 files changed

+66
-48
lines changed

Diff for: library/Xi/Filelib/Asynchrony/FileRepository.php

+29-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class FileRepository implements FileRepositoryInterface
2020
{
2121
const COMMAND_UPLOAD = 'xi_filelib.asynchrony.upload';
2222
const COMMAND_AFTERUPLOAD = 'xi_filelib.asynchrony.afterUpload';
23+
const COMMAND_DELETE = 'xi_filelib.asynchrony.delete';
24+
const COMMAND_UPDATE = 'xi_filelib.asynchrony.update';
25+
const COMMAND_COPY = 'xi_filelib.asynchrony.copy';
2326

2427
/**
2528
* @var FileRepositoryInterface
@@ -46,6 +49,9 @@ public function __construct(
4649
$this->strategies = [
4750
self::COMMAND_UPLOAD => ExecutionStrategies::STRATEGY_SYNC,
4851
self::COMMAND_AFTERUPLOAD => ExecutionStrategies::STRATEGY_SYNC,
52+
self::COMMAND_DELETE => ExecutionStrategies::STRATEGY_SYNC,
53+
self::COMMAND_UPDATE => ExecutionStrategies::STRATEGY_SYNC,
54+
self::COMMAND_COPY => ExecutionStrategies::STRATEGY_SYNC,
4955
];
5056
}
5157

@@ -127,7 +133,13 @@ public function afterUpload(File $file)
127133
*/
128134
public function update(File $file)
129135
{
130-
return $this->innerRepository->update($file);
136+
return $this->execute(
137+
self::COMMAND_UPDATE,
138+
[$this->innerRepository, 'update'],
139+
[
140+
$file,
141+
]
142+
);
131143
}
132144

133145
/**
@@ -196,7 +208,13 @@ public function findAll()
196208
*/
197209
public function delete(File $file)
198210
{
199-
return $this->innerRepository->delete($file);
211+
return $this->execute(
212+
self::COMMAND_DELETE,
213+
[$this->innerRepository, 'delete'],
214+
[
215+
$file,
216+
]
217+
);
200218
}
201219

202220
/**
@@ -207,7 +225,14 @@ public function delete(File $file)
207225
*/
208226
public function copy(File $file, Folder $folder)
209227
{
210-
return $this->innerRepository->copy($file, $folder);
228+
return $this->execute(
229+
self::COMMAND_COPY,
230+
[$this->innerRepository, 'copy'],
231+
[
232+
$file,
233+
$folder
234+
]
235+
);
211236
}
212237

213238
/**
@@ -224,4 +249,4 @@ private function execute($command, $callback, $params)
224249

225250
return $strategy->execute($callback, $params);
226251
}
227-
}
252+
}

Diff for: tests/Xi/Filelib/Tests/Asynchrony/FileRepositoryTest.php

+37-44
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,42 @@ public function afterUploads()
8585
$this->assertEquals('jippikaijea', $ret);
8686
}
8787

88+
/**
89+
* @test
90+
*/
91+
public function copies()
92+
{
93+
$file = File::create();
94+
$folder = Folder::create();
95+
96+
$this->repo->copy($file, $folder)->shouldBeCalled()->willReturn('jippikaijea');
97+
$ret = $this->filelib->getFileRepository()->copy($file, $folder);
98+
$this->assertEquals('jippikaijea', $ret);
99+
}
100+
101+
102+
/**
103+
* @test
104+
*/
105+
public function deletes()
106+
{
107+
$file = File::create();
108+
109+
$this->repo->delete($file)->shouldBeCalled()->willReturn('jippikaijea');
110+
$ret = $this->filelib->getFileRepository()->delete($file);
111+
$this->assertEquals('jippikaijea', $ret);
112+
}
113+
114+
/**
115+
* @test
116+
*/
117+
public function updates()
118+
{
119+
$file = File::create();
120+
$this->repo->update($file)->shouldBeCalled()->willReturn('jippikaijea');
121+
$ret = $this->filelib->getFileRepository()->update($file);
122+
$this->assertEquals('jippikaijea', $ret);
123+
}
88124

89125
/**
90126
* @test
@@ -111,10 +147,6 @@ public function setsStrategy()
111147
'xooxer',
112148
$this->filelib->getFileRepository()->getExecutionStrategy(FileRepository::COMMAND_AFTERUPLOAD)
113149
);
114-
115-
116-
117-
118150
}
119151

120152
/**
@@ -198,31 +230,6 @@ public function findByUuidDelegates()
198230
$this->assertEquals($expected, $ret);
199231
}
200232

201-
/**
202-
* @test
203-
*/
204-
public function updateDelegates()
205-
{
206-
$param = File::create();
207-
$expected = 'tus';
208-
209-
$this->repo->update($param)->shouldBeCalled()->willReturn($expected);
210-
$ret = $this->filelib->getFileRepository()->update($param);
211-
$this->assertEquals($expected, $ret);
212-
}
213-
214-
/**
215-
* @test
216-
*/
217-
public function deleteDelegates()
218-
{
219-
$param = File::create();
220-
$expected = 'tus';
221-
222-
$this->repo->delete($param)->shouldBeCalled()->willReturn($expected);
223-
$ret = $this->filelib->getFileRepository()->delete($param);
224-
$this->assertEquals($expected, $ret);
225-
}
226233

227234
/**
228235
* @test
@@ -249,18 +256,4 @@ public function findByFilenameDelegates()
249256
$ret = $this->filelib->getFileRepository()->findByFilename($param1, $param2);
250257
$this->assertEquals($expected, $ret);
251258
}
252-
253-
/**
254-
* @test
255-
*/
256-
public function copyDelegates()
257-
{
258-
$param1 = File::create();
259-
$param2 = Folder::create();
260-
$expected = 'tus';
261-
262-
$this->repo->copy($param1, $param2)->shouldBeCalled()->willReturn($expected);
263-
$ret = $this->filelib->getFileRepository()->copy($param1, $param2);
264-
$this->assertEquals($expected, $ret);
265-
}
266-
}
259+
}

0 commit comments

Comments
 (0)