Skip to content

Commit 612eb6b

Browse files
Removendo alguns testes desnecessários e refatorando outros.
1 parent cf3968e commit 612eb6b

4 files changed

Lines changed: 62 additions & 108 deletions

File tree

tests/AllHolidaysTest.php

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function setUp()
1111
$this->actualYear = (int) date('Y');
1212
}
1313

14-
public function testAssertEqualLengthCollection()
14+
public function testAssertEqualsLengthCollection()
1515
{
1616
$this->assertEquals(19, $this->collection->length());
1717
}
@@ -193,42 +193,6 @@ public function testAssertInstanceOfLastElementCollectionOrderByTimestampDescend
193193
);
194194
}
195195

196-
public function testAssertEqualsFormatterDate()
197-
{
198-
$this->assertEquals(
199-
(new \Holidays\Types\NewYearsDay())->formatter(),
200-
$this->collection
201-
->orderByTimestamp()
202-
->descending()
203-
->last()
204-
->formatter()
205-
);
206-
}
207-
208-
public function testAssertEqualsNextHolidayFormatter()
209-
{
210-
$this->assertEquals(
211-
(new \Holidays\Types\NewYearsDay())->next(),
212-
$this->collection
213-
->orderByTimestamp()
214-
->descending()
215-
->last()
216-
->next()
217-
);
218-
}
219-
220-
public function testAssertEqualsPreviousHolidayFormatter()
221-
{
222-
$this->assertEquals(
223-
(new \Holidays\Types\NewYearsDay())->previous(),
224-
$this->collection
225-
->orderByTimestamp()
226-
->descending()
227-
->last()
228-
->previous()
229-
);
230-
}
231-
232196
public function testExpectedExceptionDates()
233197
{
234198
$endDate = \DateTime::createFromFormat('d/m/Y', '01/01/2020')->setTime(0,0,0);

tests/NationalHolidaysTest.php

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
<?php
22

3-
use Holidays\Collections\NationalHolidays;
4-
53
class NationalHolidaysTest extends \PHPUnit_Framework_TestCase
64
{
75
private $collection;
6+
private $actualYear;
87

98
public function setUp() {
10-
$this->collection = new NationalHolidays();
9+
$this->collection = new Holidays\Collections\NationalHolidays();
10+
$this->actualYear = (int) date('Y');
1111
}
1212

13-
public function testCountCollection()
13+
public function testAssertEqualsLengthCollection()
1414
{
15-
$this->assertCount(
16-
11,
17-
$this->collection->getCollection()
18-
);
15+
$this->assertEquals(11, $this->collection->length());
1916
}
2017

2118
public function testAssertEqualPluckByName()
@@ -164,26 +161,26 @@ public function testAssertInstanceOfLastElementCollectionOrderByTimestampDescend
164161
);
165162
}
166163

167-
private function expectedCollectionDefault()
164+
private function expectedCollectionDefault($year)
168165
{
169166
return [
170-
new \Holidays\Types\AllSoulsDay(),
171-
new \Holidays\Types\ChildrenDay(),
172-
new \Holidays\Types\ChristmasDay(),
173-
new \Holidays\Types\EasterSunday(),
174-
new \Holidays\Types\GoodFriday(),
175-
new \Holidays\Types\IndependenceBrazil(),
176-
new \Holidays\Types\LaborDay(),
177-
new \Holidays\Types\NewYearsDay(),
178-
new \Holidays\Types\OurLadyOfAparecida(),
179-
new \Holidays\Types\RepublicProclamationDay(),
180-
new \Holidays\Types\TiradentesDay(),
167+
new \Holidays\Types\AllSoulsDay($year),
168+
new \Holidays\Types\ChildrenDay($year),
169+
new \Holidays\Types\ChristmasDay($year),
170+
new \Holidays\Types\EasterSunday($year),
171+
new \Holidays\Types\GoodFriday($year),
172+
new \Holidays\Types\IndependenceBrazil($year),
173+
new \Holidays\Types\LaborDay($year),
174+
new \Holidays\Types\NewYearsDay($year),
175+
new \Holidays\Types\OurLadyOfAparecida($year),
176+
new \Holidays\Types\RepublicProclamationDay($year),
177+
new \Holidays\Types\TiradentesDay($year),
181178
];
182179
}
183180

184181
private function expectedCollectionOrderByNameAscending()
185182
{
186-
$collection = $this->expectedCollectionDefault();
183+
$collection = $this->expectedCollectionDefault($this->getActualYear());
187184

188185
usort($collection, function(\Holidays\Contract\Holiday $a, \Holidays\Contract\Holiday $b) {
189186
return $a->getName() > $b->getName();
@@ -199,7 +196,7 @@ private function expectedCollectionOrderByNameDescending()
199196

200197
private function expectedCollectionOrderByTimestampAscending()
201198
{
202-
$collection = $this->expectedCollectionDefault();
199+
$collection = $this->expectedCollectionDefault($this->getActualYear());
203200

204201
usort($collection, function(\Holidays\Contract\Holiday $a, \Holidays\Contract\Holiday $b) {
205202
return $a->getTimestamp() > $b->getTimestamp();
@@ -210,12 +207,17 @@ private function expectedCollectionOrderByTimestampAscending()
210207

211208
private function expectedCollectionOrderByTimestampDescending()
212209
{
213-
$collection = $this->expectedCollectionDefault();
210+
$collection = $this->expectedCollectionDefault($this->getActualYear());
214211

215212
usort($collection, function(\Holidays\Contract\Holiday $a, \Holidays\Contract\Holiday $b) {
216213
return $a->getTimestamp() < $b->getTimestamp();
217214
});
218215

219216
return $collection;
220217
}
218+
219+
public function getActualYear()
220+
{
221+
return $this->actualYear;
222+
}
221223
}

tests/OptionalHolidaysTest.php

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
11
<?php
22

3-
use Holidays\Collections\OptionalHolidays;
4-
53
class OptionalHolidaysTest extends \PHPUnit_Framework_TestCase
64
{
75
private $collection;
6+
private $actualYear;
87

98
public function setUp() {
10-
$this->collection = new OptionalHolidays();
11-
}
12-
13-
public function testAssertEqualsOptionalHolidaysCollection()
14-
{
15-
$this->assertEquals(
16-
$this->expectedCollectionDefault(),
17-
$this->collection->getCollection()
18-
);
9+
$this->collection = new Holidays\Collections\OptionalHolidays();
10+
$this->actualYear = (int) date('Y');
1911
}
2012

21-
public function testCountCollection()
13+
public function testAssertEqualsLengthCollection()
2214
{
23-
$this->assertCount(
24-
4,
25-
$this->collection->getCollection()
26-
);
15+
$this->assertEquals(4, $this->collection->length());
2716
}
2817

2918
public function testAssertEqualPluckByName()
@@ -188,19 +177,19 @@ public function testAssertInstanceOfLastElementCollectionOrderByTimestampDescend
188177
);
189178
}
190179

191-
private function expectedCollectionDefault()
180+
private function expectedCollectionDefault($year)
192181
{
193182
return [
194-
new \Holidays\Types\Carnival(),
195-
new \Holidays\Types\CorpusChrist(),
196-
new \Holidays\Types\FatherDay(),
197-
new \Holidays\Types\MotherDay(),
183+
new \Holidays\Types\Carnival($year),
184+
new \Holidays\Types\CorpusChrist($year),
185+
new \Holidays\Types\FatherDay($year),
186+
new \Holidays\Types\MotherDay($year),
198187
];
199188
}
200189

201190
private function expectedCollectionOrderByNameAscending()
202191
{
203-
$collection = $this->expectedCollectionDefault();
192+
$collection = $this->expectedCollectionDefault($this->getActualYear());
204193

205194
usort($collection, function(\Holidays\Contract\Holiday $a, \Holidays\Contract\Holiday $b) {
206195
return $a->getName() > $b->getName();
@@ -216,7 +205,7 @@ private function expectedCollectionOrderByNameDescending()
216205

217206
private function expectedCollectionOrderByTimestampAscending()
218207
{
219-
$collection = $this->expectedCollectionDefault();
208+
$collection = $this->expectedCollectionDefault($this->getActualYear());
220209

221210
usort($collection, function(\Holidays\Contract\Holiday $a, \Holidays\Contract\Holiday $b) {
222211
return $a->getTimestamp() > $b->getTimestamp();
@@ -227,12 +216,17 @@ private function expectedCollectionOrderByTimestampAscending()
227216

228217
private function expectedCollectionOrderByTimestampDescending()
229218
{
230-
$collection = $this->expectedCollectionDefault();
219+
$collection = $this->expectedCollectionDefault($this->getActualYear());
231220

232221
usort($collection, function(\Holidays\Contract\Holiday $a, \Holidays\Contract\Holiday $b) {
233222
return $a->getTimestamp() < $b->getTimestamp();
234223
});
235224

236225
return $collection;
237226
}
227+
228+
public function getActualYear()
229+
{
230+
return $this->actualYear;
231+
}
238232
}

tests/SeasonsTest.php

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
11
<?php
22

3-
use Holidays\Collections\Seasons;
4-
53
class SeasonsTest extends \PHPUnit_Framework_TestCase
64
{
75
private $collection;
6+
private $actualYear;
87

98
public function setUp() {
10-
$this->collection = new Seasons();
11-
}
12-
13-
public function testAssertEqualsSeasonsCollection()
14-
{
15-
$this->assertEquals(
16-
$this->expectedCollectionDefault(),
17-
$this->collection->getCollection()
18-
);
9+
$this->collection = new Holidays\Collections\Seasons();
10+
$this->actualYear = (int) date('Y');
1911
}
2012

21-
public function testCountCollection()
13+
public function testAssertEqualsLengthCollection()
2214
{
23-
$this->assertCount(
24-
4,
25-
$this->collection->getCollection()
26-
);
15+
$this->assertEquals(4,$this->collection->length());
2716
}
2817

2918
public function testAssertEqualPluckByName()
@@ -188,19 +177,19 @@ public function testAssertInstanceOfLastElementCollectionOrderByTimestampDescend
188177
);
189178
}
190179

191-
private function expectedCollectionDefault()
180+
private function expectedCollectionDefault($year)
192181
{
193182
return [
194-
new Holidays\Types\DecemberSolstice(),
195-
new Holidays\Types\JuneSolstice(),
196-
new Holidays\Types\MarchEquinox(),
197-
new Holidays\Types\SeptemberEquinox(),
183+
new Holidays\Types\DecemberSolstice($year),
184+
new Holidays\Types\JuneSolstice($year),
185+
new Holidays\Types\MarchEquinox($year),
186+
new Holidays\Types\SeptemberEquinox($year),
198187
];
199188
}
200189

201190
private function expectedCollectionOrderByNameAscending()
202191
{
203-
$collection = $this->expectedCollectionDefault();
192+
$collection = $this->expectedCollectionDefault($this->getActualYear());
204193

205194
usort($collection, function(\Holidays\Contract\Holiday $a, \Holidays\Contract\Holiday $b) {
206195
return $a->getName() > $b->getName();
@@ -216,7 +205,7 @@ private function expectedCollectionOrderByNameDescending()
216205

217206
private function expectedCollectionOrderByTimestampAscending()
218207
{
219-
$collection = $this->expectedCollectionDefault();
208+
$collection = $this->expectedCollectionDefault($this->getActualYear());
220209

221210
usort($collection, function(\Holidays\Contract\Holiday $a, \Holidays\Contract\Holiday $b) {
222211
return $a->getTimestamp() > $b->getTimestamp();
@@ -227,12 +216,17 @@ private function expectedCollectionOrderByTimestampAscending()
227216

228217
private function expectedCollectionOrderByTimestampDescending()
229218
{
230-
$collection = $this->expectedCollectionDefault();
219+
$collection = $this->expectedCollectionDefault($this->getActualYear());
231220

232221
usort($collection, function(\Holidays\Contract\Holiday $a, \Holidays\Contract\Holiday $b) {
233222
return $a->getTimestamp() < $b->getTimestamp();
234223
});
235224

236225
return $collection;
237226
}
227+
228+
public function getActualYear()
229+
{
230+
return $this->actualYear;
231+
}
238232
}

0 commit comments

Comments
 (0)