mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 22:35:01 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -18,6 +18,7 @@ use PHPUnit\Framework\TestCase;
|
||||
* tests for CountriesInfos.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class CountriesInfoTest extends TestCase
|
||||
|
@@ -12,36 +12,34 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Tests\Util;
|
||||
|
||||
use Chill\MainBundle\Util\DateRangeCovering;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use function usort;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class DateRangeCoveringTest extends TestCase
|
||||
{
|
||||
public function testCoveringWithMinCover1()
|
||||
{
|
||||
$cover = new DateRangeCovering(1, new DateTimeZone('Europe/Brussels'));
|
||||
$cover = new DateRangeCovering(1, new \DateTimeZone('Europe/Brussels'));
|
||||
$cover
|
||||
->add(new DateTime('2010-01-01'), new DateTime('2010-12-01'), 1)
|
||||
->add(new DateTime('2010-06-01'), new DateTime('2011-06-01'), 2)
|
||||
->add(new DateTime('2019-06-01'), new DateTime('2019-06-01'), 3)
|
||||
->add(new \DateTime('2010-01-01'), new \DateTime('2010-12-01'), 1)
|
||||
->add(new \DateTime('2010-06-01'), new \DateTime('2011-06-01'), 2)
|
||||
->add(new \DateTime('2019-06-01'), new \DateTime('2019-06-01'), 3)
|
||||
->compute();
|
||||
|
||||
$this->assertTrue($cover->hasIntersections());
|
||||
$this->assertIsArray($cover->getIntersections());
|
||||
$this->assertCount(1, $cover->getIntersections());
|
||||
$this->assertEquals(
|
||||
new DateTime('2010-06-01'),
|
||||
new \DateTime('2010-06-01'),
|
||||
$cover->getIntersections()[0][0],
|
||||
'assert date start are the intersection'
|
||||
);
|
||||
$this->assertEquals(
|
||||
new DateTime('2010-12-01'),
|
||||
new \DateTime('2010-12-01'),
|
||||
$cover->getIntersections()[0][1],
|
||||
'assert date end are the intersection'
|
||||
);
|
||||
@@ -53,10 +51,10 @@ final class DateRangeCoveringTest extends TestCase
|
||||
|
||||
public function testCoveringWithMinCover1NoCoveringWithNullDates()
|
||||
{
|
||||
$cover = new DateRangeCovering(1, new DateTimeZone('Europe/Brussels'));
|
||||
$cover = new DateRangeCovering(1, new \DateTimeZone('Europe/Brussels'));
|
||||
$cover
|
||||
->add(new DateTime('2021-10-05'), new DateTime('2021-10-18'), 521)
|
||||
->add(new DateTime('2021-10-26'), null, 663)
|
||||
->add(new \DateTime('2021-10-05'), new \DateTime('2021-10-18'), 521)
|
||||
->add(new \DateTime('2021-10-26'), null, 663)
|
||||
->compute();
|
||||
|
||||
$this->assertFalse($cover->hasIntersections());
|
||||
@@ -64,12 +62,12 @@ final class DateRangeCoveringTest extends TestCase
|
||||
|
||||
public function testCoveringWithMinCover1WithTwoIntersections()
|
||||
{
|
||||
$cover = new DateRangeCovering(1, new DateTimeZone('Europe/Brussels'));
|
||||
$cover = new DateRangeCovering(1, new \DateTimeZone('Europe/Brussels'));
|
||||
$cover
|
||||
->add(new DateTime('2010-01-01'), new DateTime('2010-12-01'), 1)
|
||||
->add(new DateTime('2010-06-01'), new DateTime('2011-06-01'), 2)
|
||||
->add(new DateTime('2019-01-01'), new DateTime('2019-12-01'), 3)
|
||||
->add(new DateTime('2019-06-01'), new DateTime('2020-06-01'), 4)
|
||||
->add(new \DateTime('2010-01-01'), new \DateTime('2010-12-01'), 1)
|
||||
->add(new \DateTime('2010-06-01'), new \DateTime('2011-06-01'), 2)
|
||||
->add(new \DateTime('2019-01-01'), new \DateTime('2019-12-01'), 3)
|
||||
->add(new \DateTime('2019-06-01'), new \DateTime('2020-06-01'), 4)
|
||||
->compute();
|
||||
|
||||
$this->assertTrue($cover->hasIntersections());
|
||||
@@ -79,7 +77,7 @@ final class DateRangeCoveringTest extends TestCase
|
||||
$intersections = $cover->getIntersections();
|
||||
|
||||
// sort the intersections to compare them in expected order
|
||||
usort($intersections, static function ($a, $b) {
|
||||
\usort($intersections, static function ($a, $b) {
|
||||
if ($a[0] === $b[0]) {
|
||||
return $a[1] <=> $b[1];
|
||||
}
|
||||
@@ -89,12 +87,12 @@ final class DateRangeCoveringTest extends TestCase
|
||||
|
||||
// first intersection
|
||||
$this->assertEquals(
|
||||
new DateTime('2010-06-01'),
|
||||
new \DateTime('2010-06-01'),
|
||||
$intersections[0][0],
|
||||
'assert date start are the intersection'
|
||||
);
|
||||
$this->assertEquals(
|
||||
new DateTime('2010-12-01'),
|
||||
new \DateTime('2010-12-01'),
|
||||
$intersections[0][1],
|
||||
'assert date end are the intersection'
|
||||
);
|
||||
@@ -106,12 +104,12 @@ final class DateRangeCoveringTest extends TestCase
|
||||
|
||||
// second intersection
|
||||
$this->assertEquals(
|
||||
new DateTime('2019-06-01'),
|
||||
new \DateTime('2019-06-01'),
|
||||
$intersections[1][0],
|
||||
'assert date start are the intersection'
|
||||
);
|
||||
$this->assertEquals(
|
||||
new DateTime('2019-12-01'),
|
||||
new \DateTime('2019-12-01'),
|
||||
$intersections[1][1],
|
||||
'assert date end are the intersection'
|
||||
);
|
||||
@@ -124,25 +122,25 @@ final class DateRangeCoveringTest extends TestCase
|
||||
|
||||
public function testCoveringWithMinCover2()
|
||||
{
|
||||
$cover = new DateRangeCovering(2, new DateTimeZone('Europe/Brussels'));
|
||||
$cover = new DateRangeCovering(2, new \DateTimeZone('Europe/Brussels'));
|
||||
$cover
|
||||
->add(new DateTime('2010-01-01'), new DateTime('2010-10-01'), 1)
|
||||
->add(new DateTime('2010-06-01'), new DateTime('2010-09-01'), 2)
|
||||
->add(new DateTime('2010-04-01'), new DateTime('2010-12-01'), 3)
|
||||
->add(new DateTime('2019-01-01'), new DateTime('2019-10-01'), 4)
|
||||
->add(new DateTime('2019-06-01'), new DateTime('2019-09-01'), 5)
|
||||
->add(new \DateTime('2010-01-01'), new \DateTime('2010-10-01'), 1)
|
||||
->add(new \DateTime('2010-06-01'), new \DateTime('2010-09-01'), 2)
|
||||
->add(new \DateTime('2010-04-01'), new \DateTime('2010-12-01'), 3)
|
||||
->add(new \DateTime('2019-01-01'), new \DateTime('2019-10-01'), 4)
|
||||
->add(new \DateTime('2019-06-01'), new \DateTime('2019-09-01'), 5)
|
||||
->compute();
|
||||
$this->assertTrue($cover->hasIntersections());
|
||||
$this->assertIsArray($cover->getIntersections());
|
||||
$this->assertCount(1, $cover->getIntersections());
|
||||
|
||||
$this->assertEquals(
|
||||
new DateTime('2010-06-01'),
|
||||
new \DateTime('2010-06-01'),
|
||||
$cover->getIntersections()[0][0],
|
||||
'assert date start are the intersection'
|
||||
);
|
||||
$this->assertEquals(
|
||||
new DateTime('2010-09-01'),
|
||||
new \DateTime('2010-09-01'),
|
||||
$cover->getIntersections()[0][1],
|
||||
'assert date end are the intersection'
|
||||
);
|
||||
@@ -156,14 +154,14 @@ final class DateRangeCoveringTest extends TestCase
|
||||
|
||||
public function testCoveringWithMinCover2AndThreePeriodsCovering()
|
||||
{
|
||||
$cover = new DateRangeCovering(2, new DateTimeZone('Europe/Brussels'));
|
||||
$cover = new DateRangeCovering(2, new \DateTimeZone('Europe/Brussels'));
|
||||
$cover
|
||||
->add(new DateTime('2010-01-01'), new DateTime('2010-10-01'), 1)
|
||||
->add(new DateTime('2010-06-01'), new DateTime('2010-09-01'), 2)
|
||||
->add(new DateTime('2010-04-01'), new DateTime('2010-12-01'), 3)
|
||||
->add(new DateTime('2009-01-01'), new DateTime('2010-09-15'), 4)
|
||||
->add(new DateTime('2019-01-01'), new DateTime('2019-10-01'), 5)
|
||||
->add(new DateTime('2019-06-01'), new DateTime('2019-09-01'), 6)
|
||||
->add(new \DateTime('2010-01-01'), new \DateTime('2010-10-01'), 1)
|
||||
->add(new \DateTime('2010-06-01'), new \DateTime('2010-09-01'), 2)
|
||||
->add(new \DateTime('2010-04-01'), new \DateTime('2010-12-01'), 3)
|
||||
->add(new \DateTime('2009-01-01'), new \DateTime('2010-09-15'), 4)
|
||||
->add(new \DateTime('2019-01-01'), new \DateTime('2019-10-01'), 5)
|
||||
->add(new \DateTime('2019-06-01'), new \DateTime('2019-09-01'), 6)
|
||||
->compute();
|
||||
|
||||
$this->assertTrue($cover->hasIntersections());
|
||||
@@ -171,12 +169,12 @@ final class DateRangeCoveringTest extends TestCase
|
||||
$this->assertCount(1, $cover->getIntersections());
|
||||
|
||||
$this->assertEquals(
|
||||
new DateTime('2010-04-01'),
|
||||
new \DateTime('2010-04-01'),
|
||||
$cover->getIntersections()[0][0],
|
||||
'assert date start are the intersection'
|
||||
);
|
||||
$this->assertEquals(
|
||||
new DateTime('2010-09-15'),
|
||||
new \DateTime('2010-09-15'),
|
||||
$cover->getIntersections()[0][1],
|
||||
'assert date end are the intersection'
|
||||
);
|
||||
@@ -191,14 +189,14 @@ final class DateRangeCoveringTest extends TestCase
|
||||
|
||||
public function testCoveringWithMinCover2AndThreePeriodsCoveringWithNullMetadata()
|
||||
{
|
||||
$cover = new DateRangeCovering(2, new DateTimeZone('Europe/Brussels'));
|
||||
$cover = new DateRangeCovering(2, new \DateTimeZone('Europe/Brussels'));
|
||||
$cover
|
||||
->add(new DateTime('2010-01-01'), new DateTime('2010-10-01'), null)
|
||||
->add(new DateTime('2010-06-01'), new DateTime('2010-09-01'), null)
|
||||
->add(new DateTime('2010-04-01'), new DateTime('2010-12-01'), null)
|
||||
->add(new DateTime('2009-01-01'), new DateTime('2010-09-15'), null)
|
||||
->add(new DateTime('2019-01-01'), new DateTime('2019-10-01'), null)
|
||||
->add(new DateTime('2019-06-01'), new DateTime('2019-09-01'), null)
|
||||
->add(new \DateTime('2010-01-01'), new \DateTime('2010-10-01'), null)
|
||||
->add(new \DateTime('2010-06-01'), new \DateTime('2010-09-01'), null)
|
||||
->add(new \DateTime('2010-04-01'), new \DateTime('2010-12-01'), null)
|
||||
->add(new \DateTime('2009-01-01'), new \DateTime('2010-09-15'), null)
|
||||
->add(new \DateTime('2019-01-01'), new \DateTime('2019-10-01'), null)
|
||||
->add(new \DateTime('2019-06-01'), new \DateTime('2019-09-01'), null)
|
||||
->compute();
|
||||
|
||||
$this->assertTrue($cover->hasIntersections());
|
||||
@@ -206,12 +204,12 @@ final class DateRangeCoveringTest extends TestCase
|
||||
$this->assertCount(1, $cover->getIntersections());
|
||||
|
||||
$this->assertEquals(
|
||||
new DateTime('2010-04-01'),
|
||||
new \DateTime('2010-04-01'),
|
||||
$cover->getIntersections()[0][0],
|
||||
'assert date start are the intersection'
|
||||
);
|
||||
$this->assertEquals(
|
||||
new DateTime('2010-09-15'),
|
||||
new \DateTime('2010-09-15'),
|
||||
$cover->getIntersections()[0][1],
|
||||
'assert date end are the intersection'
|
||||
);
|
||||
@@ -220,13 +218,13 @@ final class DateRangeCoveringTest extends TestCase
|
||||
|
||||
public function testCoveringWithMinCover3Absent()
|
||||
{
|
||||
$cover = new DateRangeCovering(3, new DateTimeZone('Europe/Brussels'));
|
||||
$cover = new DateRangeCovering(3, new \DateTimeZone('Europe/Brussels'));
|
||||
$cover
|
||||
->add(new DateTime('2010-01-01'), new DateTime('2010-10-01'), 1)
|
||||
->add(new DateTime('2010-06-01'), new DateTime('2010-09-01'), 2)
|
||||
->add(new DateTime('2010-04-01'), new DateTime('2010-12-01'), 3)
|
||||
->add(new DateTime('2019-01-01'), new DateTime('2019-10-01'), 4)
|
||||
->add(new DateTime('2019-06-01'), new DateTime('2019-09-01'), 5)
|
||||
->add(new \DateTime('2010-01-01'), new \DateTime('2010-10-01'), 1)
|
||||
->add(new \DateTime('2010-06-01'), new \DateTime('2010-09-01'), 2)
|
||||
->add(new \DateTime('2010-04-01'), new \DateTime('2010-12-01'), 3)
|
||||
->add(new \DateTime('2019-01-01'), new \DateTime('2019-10-01'), 4)
|
||||
->add(new \DateTime('2019-06-01'), new \DateTime('2019-09-01'), 5)
|
||||
->compute();
|
||||
$this->assertFalse($cover->hasIntersections());
|
||||
$this->assertIsArray($cover->getIntersections());
|
||||
|
Reference in New Issue
Block a user