Skip to content

Commit

Permalink
DataProviders generators. (#2412)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmichot authored Aug 8, 2021
1 parent 570841f commit 83e4cb8
Show file tree
Hide file tree
Showing 25 changed files with 1,582 additions and 1,648 deletions.
57 changes: 25 additions & 32 deletions tests/Carbon/AddMonthsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Tests\Carbon;

use Carbon\Carbon;
use Generator;
use Tests\AbstractTestCase;

class AddMonthsTest extends AbstractTestCase
Expand All @@ -31,15 +32,13 @@ protected function setUp(): void
$this->carbon = $date;
}

public function providerTestAddMonthNoOverflow()
public function providerTestAddMonthNoOverflow(): Generator
{
return [
[-2, 2015, 11, 30],
[-1, 2015, 12, 31],
[0, 2016, 1, 31],
[1, 2016, 2, 29],
[2, 2016, 3, 31],
];
yield [-2, 2015, 11, 30];
yield [-1, 2015, 12, 31];
yield [0, 2016, 1, 31];
yield [1, 2016, 2, 29];
yield [2, 2016, 3, 31];
}

/**
Expand Down Expand Up @@ -68,15 +67,13 @@ public function testAddMonthsNoOverflow($months, $y, $m, $d)
$this->assertCarbon($this->carbon->addMonthsNoOverflow($months), $y, $m, $d);
}

public function providerTestSubMonthNoOverflow()
public function providerTestSubMonthNoOverflow(): Generator
{
return [
[-2, 2016, 3, 31],
[-1, 2016, 2, 29],
[0, 2016, 1, 31],
[1, 2015, 12, 31],
[2, 2015, 11, 30],
];
yield [-2, 2016, 3, 31];
yield [-1, 2016, 2, 29];
yield [0, 2016, 1, 31];
yield [1, 2015, 12, 31];
yield [2, 2015, 11, 30];
}

/**
Expand Down Expand Up @@ -105,15 +102,13 @@ public function testSubMonthsNoOverflow($months, $y, $m, $d)
$this->assertCarbon($this->carbon->subMonthsNoOverflow($months), $y, $m, $d);
}

public function providerTestAddMonthWithOverflow()
public function providerTestAddMonthWithOverflow(): Generator
{
return [
[-2, 2015, 12, 1],
[-1, 2015, 12, 31],
[0, 2016, 1, 31],
[1, 2016, 3, 2],
[2, 2016, 3, 31],
];
yield [-2, 2015, 12, 1];
yield [-1, 2015, 12, 31];
yield [0, 2016, 1, 31];
yield [1, 2016, 3, 2];
yield [2, 2016, 3, 31];
}

/**
Expand Down Expand Up @@ -142,15 +137,13 @@ public function testAddMonthsWithOverflow($months, $y, $m, $d)
$this->assertCarbon($this->carbon->addMonthsWithOverflow($months), $y, $m, $d);
}

public function providerTestSubMonthWithOverflow()
public function providerTestSubMonthWithOverflow(): Generator
{
return [
[-2, 2016, 3, 31],
[-1, 2016, 3, 2],
[0, 2016, 1, 31],
[1, 2015, 12, 31],
[2, 2015, 12, 1],
];
yield [-2, 2016, 3, 31];
yield [-1, 2016, 3, 2];
yield [0, 2016, 1, 31];
yield [1, 2015, 12, 31];
yield [2, 2015, 12, 1];
}

/**
Expand Down
Loading

0 comments on commit 83e4cb8

Please sign in to comment.