Skip to content

Commit

Permalink
✅ Adding phpunit
Browse files Browse the repository at this point in the history
  • Loading branch information
contactinquid committed Dec 7, 2023
1 parent cc0cf33 commit 53f3846
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
11 changes: 11 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
"ShibuyaKosuke\\LaravelYasumi\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"ShibuyaKosuke\\LaravelYasumi\\Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"providers": [
Expand All @@ -27,5 +32,11 @@
"Holiday": "ShibuyaKosuke\\LaravelYasumi\\Facades\\Holiday"
}
}
},
"scripts": {
"test": "vendor/bin/phpunit"
},
"require-dev": {
"phpunit/phpunit": "^10.5"
}
}
17 changes: 17 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache">
<coverage/>
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_ENV" value="testing"/>
</php>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
26 changes: 26 additions & 0 deletions tests/HolidayTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace ShibuyaKosuke\LaravelYasumi\Tests;

use Illuminate\Config\Repository;
use Illuminate\Support\Carbon;
use ShibuyaKosuke\LaravelYasumi\Holiday;

class HolidayTest extends TestCase
{
public function testCanGetHolidays(): void
{
$config = new Repository([
'yasumi' => [
'country' => 'Japan',
'locale' => 'ja_JP'
]
]);
$holiday = new Holiday($config);
$newYear = Carbon::make('2020-01-01');
$holidayResult = $holiday->get($newYear);
$this->assertEquals('元日', $holidayResult);
}
}
10 changes: 10 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace ShibuyaKosuke\LaravelYasumi\Tests;

abstract class TestCase extends \PHPUnit\Framework\TestCase
{

}

0 comments on commit 53f3846

Please sign in to comment.