Skip to content

Commit

Permalink
Basic usage test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Hall committed Jan 11, 2018
1 parent 9691c7d commit 4a873ee
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 1 deletion.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"php": ">=5.3",
"rapidwebltd/rw-file-cache": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7"
},
"autoload": {
"psr-4": {
"RapidWeb\\UkBankHolidays\\": "./src/"
Expand Down
25 changes: 25 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit Tests">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Functional Tests">
<directory suffix="Test.php">./tests/Functional</directory>
</testsuite>
</testsuites>
<filter>

</filter>
<php>

</php>
</phpunit>
2 changes: 1 addition & 1 deletion src/example.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
require_once '../vendor/autoload.php';
require_once __DIR__.'/../vendor/autoload.php';

use RapidWeb\UkBankHolidays\Factories\UkBankHolidayFactory;

Expand Down
26 changes: 26 additions & 0 deletions tests/Functional/BasicUsageTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

use PHPUnit\Framework\TestCase;

use RapidWeb\UkBankHolidays\Factories\UkBankHolidayFactory;

final class BasicUsageTest extends TestCase
{
public function testGetNewYearsDay()
{
$holidays = UkBankHolidayFactory::getByDate(2017, 01, 2);

$this->assertTrue(is_array($holidays), 'Holidays should be an array.');
$this->assertEquals(1, count($holidays), 'Holidays array should have 1 value.');

$holiday = $holidays[0];

$this->assertEquals('RapidWeb\UkBankHolidays\Objects\UkBankHoliday', get_class($holiday));

$this->assertEquals('New Year’s Day', $holiday->title);
$this->assertEquals('2017-01-02', $holiday->date);
$this->assertEquals('Substitute day', $holiday->notes);

}

}
Empty file added tests/Unit/.keep
Empty file.

0 comments on commit 4a873ee

Please sign in to comment.