1
|
|
|
<?php |
2
|
|
|
namespace Dennis\Seeder\Tests\Unit\Collection; |
3
|
|
|
|
4
|
|
|
/*************************************************************** |
5
|
|
|
* Copyright notice |
6
|
|
|
* |
7
|
|
|
* (c) 2018 Dennis Römmich <[email protected]> |
8
|
|
|
* |
9
|
|
|
* All rights reserved |
10
|
|
|
* |
11
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
12
|
|
|
* free software; you can redistribute it and/or modify |
13
|
|
|
* it under the terms of the GNU General Public License as published by |
14
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
15
|
|
|
* (at your option) any later version. |
16
|
|
|
* |
17
|
|
|
* The GNU General Public License can be found at |
18
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
19
|
|
|
* |
20
|
|
|
* This script is distributed in the hope that it will be useful, |
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23
|
|
|
* GNU General Public License for more details. |
24
|
|
|
* |
25
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
26
|
|
|
***************************************************************/ |
27
|
|
|
use TYPO3\CMS\Core\Tests\UnitTestCase; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* SeedCollectionTest |
31
|
|
|
* |
32
|
|
|
* @author Dennis Römmich<[email protected]> |
33
|
|
|
* @copyright Copyright belongs to the respective authors |
34
|
|
|
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later |
35
|
|
|
*/ |
36
|
|
|
class SeedCollectionTest extends UnitTestCase |
|
|
|
|
37
|
|
|
{ |
38
|
|
|
/** |
39
|
|
|
* @var \Dennis\Seeder\SeedCollection |
40
|
|
|
*/ |
41
|
|
|
protected $subject; |
42
|
|
|
|
43
|
|
|
public function setUp() |
44
|
|
|
{ |
45
|
|
|
$this->subject = new \Dennis\Seeder\Collection\SeedCollection(); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @method attach |
50
|
|
|
* @test |
51
|
|
|
*/ |
52
|
|
|
public function attachAttachesNewItemIfItNotExist() |
53
|
|
|
{ |
54
|
|
|
$seed = $this->getMock(\Dennis\Seeder\Seed::class); |
55
|
|
|
$this->subject->attach($seed); |
56
|
|
|
$this->assertSame($seed, $this->subject->current()['NEW1']); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @method attach |
61
|
|
|
* @test |
62
|
|
|
*/ |
63
|
|
|
public function attachAttachesOnlyOneSeedIfSeedsAreIdentical() |
64
|
|
|
{ |
65
|
|
|
$seed = $this->getMock(\Dennis\Seeder\Seed::class); |
66
|
|
|
$this->subject->attach($seed); |
67
|
|
|
$this->subject->attach($seed); |
68
|
|
|
$this->assertSame([ |
69
|
|
|
0 => 'NEW1', |
70
|
|
|
], array_keys($this->subject->current())); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @method attach |
75
|
|
|
* @test |
76
|
|
|
*/ |
77
|
|
|
public function attachAttachesMultipleSeedsIfSeedsAreDifferent() |
78
|
|
|
{ |
79
|
|
|
$seed = $this->getMock(\Dennis\Seeder\Seed::class); |
80
|
|
|
$differentSeed = $this->getMock(\Dennis\Seeder\Seed::class); |
81
|
|
|
$this->subject->attach($seed); |
82
|
|
|
$this->subject->attach($differentSeed); |
83
|
|
|
$this->assertSame([ |
84
|
|
|
0 => 'NEW1', |
85
|
|
|
1 => 'NEW2', |
86
|
|
|
], array_keys($this->subject->current())); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.