1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* Copyright 2016 Jan Eichhorn <[email protected]> |
4
|
|
|
* |
5
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
6
|
|
|
* you may not use this file except in compliance with the License. |
7
|
|
|
* You may obtain a copy of the License at |
8
|
|
|
* |
9
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
10
|
|
|
* |
11
|
|
|
* Unless required by applicable law or agreed to in writing, software |
12
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
13
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14
|
|
|
* See the License for the specific language governing permissions and |
15
|
|
|
* limitations under the License. |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
namespace ApaiIO\Test\Operations\Types; |
19
|
|
|
|
20
|
|
|
use ApaiIO\Operations\Batch; |
21
|
|
|
use ApaiIO\Operations\Lookup; |
22
|
|
|
use ApaiIO\Operations\Search; |
23
|
|
|
use PHPUnit\Framework\TestCase; |
24
|
|
|
|
25
|
|
|
class BatchTest extends TestCase |
26
|
|
|
{ |
27
|
|
|
public function testAddOperation() |
28
|
|
|
{ |
29
|
|
|
$op = new Search(); |
30
|
|
|
$op->setTest('test'); |
31
|
|
|
|
32
|
|
|
$batch = new Batch(); |
33
|
|
|
$batch->addOperation($op); |
34
|
|
|
|
35
|
|
|
$this->assertSame('ItemSearch', $batch->getName()); |
36
|
|
|
$this->assertSame(['ItemSearch.1.Test' => 'test'], $batch->getOperationParameter()); |
37
|
|
|
|
38
|
|
|
$op2 = new Lookup(); |
39
|
|
|
|
40
|
|
|
$batch->addOperation($op2); |
41
|
|
|
|
42
|
|
|
$this->assertSame('ItemSearch', $batch->getName()); |
43
|
|
|
$this->assertSame(['ItemSearch.1.Test' => 'test'], $batch->getOperationParameter()); |
44
|
|
|
|
45
|
|
|
$batch = new Batch([$op, $op2]); |
46
|
|
|
|
47
|
|
|
$this->assertSame('ItemSearch', $batch->getName()); |
48
|
|
|
$this->assertSame(['ItemSearch.1.Test' => 'test'], $batch->getOperationParameter()); |
49
|
|
|
|
50
|
|
|
$op3 = new Search(); |
51
|
|
|
$op3->setTest2('test'); |
52
|
|
|
|
53
|
|
|
$batch->addOperation($op3); |
54
|
|
|
|
55
|
|
|
$this->assertSame('ItemSearch', $batch->getName()); |
56
|
|
|
$this->assertSame([ |
57
|
|
|
'ItemSearch.1.Test' => 'test', |
58
|
|
|
'ItemSearch.2.Test2' => 'test' |
59
|
|
|
], $batch->getOperationParameter()); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|