Skip to content

Commit

Permalink
Adds failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hollodotme committed Dec 13, 2017
1 parent 5bc6500 commit 71d6c6e
Show file tree
Hide file tree
Showing 5 changed files with 245 additions and 1 deletion.
52 changes: 52 additions & 0 deletions tests/Unit/Sections/DayOfMonthSectionTest.php
Expand Up @@ -14,6 +14,58 @@
*/
final class DayOfMonthSectionTest extends TestCase
{
/**
* @param string $sectionValue
* @param string $dateString
*
* @dataProvider invalidDayOfMonthProvider
*/
public function testIsNotSatisfiedBy( string $sectionValue, string $dateString ) : void
{
$dayOfMonthSection = new DayOfMonthSection( $sectionValue );
$dateTime = new \DateTimeImmutable( $dateString );

$this->assertFalse( $dayOfMonthSection->isSatisfiedBy( $dateTime ) );
}

public function invalidDayOfMonthProvider() : array
{
return [
[
'sectionValue' => '3',
'dateString' => '2017-12-13 00:00:00',
],
[
'sectionValue' => '03',
'dateString' => '2017-12-13 00:00:00',
],
[
'sectionValue' => '*/5',
'dateString' => '2017-12-13 00:02:00',
],
# Range
[
'sectionValue' => '10-20',
'dateString' => '2017-12-09 00:30:00',
],
# List
[
'sectionValue' => '10,30',
'dateString' => '2017-12-13 00:20:00',
],
# Nearest weekday
[
'sectionValue' => '10W',
'dateString' => '2017-12-24 00:20:00',
],
# Invalid value
[
'sectionValue' => '32',
'dateString' => '2017-12-13 00:00:00',
],
];
}

/**
* @param string $sectionValue
* @param string $dateString
Expand Down
47 changes: 47 additions & 0 deletions tests/Unit/Sections/DayOfWeekSectionTest.php
Expand Up @@ -14,6 +14,53 @@
*/
final class DayOfWeekSectionTest extends TestCase
{
/**
* @param string $sectionValue
* @param string $dateString
*
* @dataProvider invalidDayOfWeekProvider
*/
public function testIsNotSatisfiedBy( string $sectionValue, string $dateString ) : void
{
$dayOfWeekSection = new DayOfWeekSection( $sectionValue );
$dateTime = new \DateTimeImmutable( $dateString );

$this->assertFalse( $dayOfWeekSection->isSatisfiedBy( $dateTime ) );
}

public function invalidDayOfWeekProvider() : array
{
return [
[
'sectionValue' => '0',
'dateString' => '2017-12-25 00:00:00',
],
[
'sectionValue' => '02',
'dateString' => '2017-12-25 00:00:00',
],
[
'sectionValue' => 'mon/2',
'dateString' => '2017-12-25 00:02:00',
],
# Range
[
'sectionValue' => '2-FRI',
'dateString' => '2017-12-25 00:30:00',
],
# List
[
'sectionValue' => 'TUE,THU',
'dateString' => '2017-12-29 00:20:00',
],
# Invalid value
[
'sectionValue' => '8',
'dateString' => '2017-12-13 00:00:00',
],
];
}

/**
* @param string $sectionValue
* @param string $dateString
Expand Down
47 changes: 47 additions & 0 deletions tests/Unit/Sections/HourSectionTest.php
Expand Up @@ -14,6 +14,53 @@
*/
final class HourSectionTest extends TestCase
{
/**
* @param string $sectionValue
* @param string $dateString
*
* @dataProvider invalidHoursProvider
*/
public function testIsNotSatisfiedBy( string $sectionValue, string $dateString ) : void
{
$hourSection = new HourSection( $sectionValue );
$dateTime = new \DateTimeImmutable( $dateString );

$this->assertFalse( $hourSection->isSatisfiedBy( $dateTime ) );
}

public function invalidHoursProvider() : array
{
return [
[
'sectionValue' => '3',
'dateString' => '2017-12-13 00:00:00',
],
[
'sectionValue' => '03',
'dateString' => '2017-12-13 01:00:00',
],
[
'sectionValue' => '*/3',
'dateString' => '2017-12-13 01:00:00',
],
# Range
[
'sectionValue' => '10-20',
'dateString' => '2017-12-13 21:00:00',
],
# List
[
'sectionValue' => '6,12',
'dateString' => '2017-12-13 07:20:00',
],
# Invalid value
[
'sectionValue' => '25',
'dateString' => '2017-12-13 00:00:00',
],
];
}

/**
* @param string $sectionValue
* @param string $dateString
Expand Down
47 changes: 47 additions & 0 deletions tests/Unit/Sections/MinuteSectionTest.php
Expand Up @@ -10,6 +10,53 @@

final class MinuteSectionTest extends TestCase
{
/**
* @param string $sectionValue
* @param string $dateString
*
* @dataProvider invalidMinutesProvider
*/
public function testIsNotSatisfiedBy( string $sectionValue, string $dateString ) : void
{
$minuteSection = new MinuteSection( $sectionValue );
$dateTime = new \DateTimeImmutable( $dateString );

$this->assertFalse( $minuteSection->isSatisfiedBy( $dateTime ) );
}

public function invalidMinutesProvider() : array
{
return [
[
'sectionValue' => '3',
'dateString' => '2017-12-13 00:00:00',
],
[
'sectionValue' => '03',
'dateString' => '2017-12-13 00:00:00',
],
[
'sectionValue' => '*/3',
'dateString' => '2017-12-13 00:02:00',
],
# Range
[
'sectionValue' => '10-20',
'dateString' => '2017-12-13 00:30:00',
],
# List
[
'sectionValue' => '10,30',
'dateString' => '2017-12-13 00:20:00',
],
# Invalid value
[
'sectionValue' => '61',
'dateString' => '2017-12-13 00:00:00',
],
];
}

/**
* @param string $sectionValue
* @param string $dateString
Expand Down
53 changes: 52 additions & 1 deletion tests/Unit/Sections/MonthSectionTest.php
Expand Up @@ -14,6 +14,57 @@
*/
final class MonthSectionTest extends TestCase
{
/**
* @param string $sectionValue
* @param string $dateString
*
* @dataProvider invalidMonthProvider
*/
public function testIsNotSatisfiedBy( string $sectionValue, string $dateString ) : void
{
$monthSection = new MonthSection( $sectionValue );
$dateTime = new \DateTimeImmutable( $dateString );

$this->assertFalse( $monthSection->isSatisfiedBy( $dateTime ) );
}

public function invalidMonthProvider() : array
{
return [
[
'sectionValue' => '3',
'dateString' => '2017-12-13 00:00:00',
],
[
'sectionValue' => '03',
'dateString' => '2017-12-13 00:00:00',
],
[
'sectionValue' => 'MAR',
'dateString' => '2017-12-13 00:00:00',
],
[
'sectionValue' => 'mar',
'dateString' => '2017-12-13 00:00:00',
],
# Range
[
'sectionValue' => 'mar-oct',
'dateString' => '2017-12-13 00:00:00',
],
# List
[
'sectionValue' => 'Apr,Nov',
'dateString' => '2017-12-13 00:00:00',
],
# Invalid value
[
'sectionValue' => 'April',
'dateString' => '2017-12-13 00:00:00',
],
];
}

/**
* @param string $sectionValue
* @param string $dateString
Expand All @@ -23,7 +74,7 @@ final class MonthSectionTest extends TestCase
public function testIsSatisfiedBy( string $sectionValue, string $dateString )
{
$monthSection = new MonthSection( $sectionValue );
$dateTime = new \DateTimeImmutable( $dateString );
$dateTime = new \DateTimeImmutable( $dateString );

$this->assertTrue( $monthSection->isSatisfiedBy( $dateTime ) );
}
Expand Down

0 comments on commit 71d6c6e

Please sign in to comment.