-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
99f6fec
commit 2d6a031
Showing
4 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Test Case | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The closure you provide to your test functions is always bound to a specific PHPUnit test | ||
| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may | ||
| need to change it using the "uses()" function to bind a different classes or traits. | ||
| | ||
*/ | ||
|
||
// uses(Tests\TestCase::class)->in('Feature'); | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Expectations | ||
|-------------------------------------------------------------------------- | ||
| | ||
| When you're writing tests, you often need to check that values meet certain conditions. The | ||
| "expect()" function gives you access to a set of "expectations" methods that you can use | ||
| to assert different things. Of course, you may extend the Expectation API at any time. | ||
| | ||
*/ | ||
|
||
expect()->extend('toBeOne', function () { | ||
return $this->toBe(1); | ||
}); | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Functions | ||
|-------------------------------------------------------------------------- | ||
| | ||
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your | ||
| project that you don't want to repeat in every file. Here you can also expose helpers as | ||
| global functions to help you to reduce the number of lines of code in your test files. | ||
| | ||
*/ | ||
|
||
function something() | ||
{ | ||
// .. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Tests; | ||
|
||
use PHPUnit\Framework\TestCase as BaseTestCase; | ||
|
||
abstract class TestCase extends BaseTestCase | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
use Omisai\Continents\Collection; | ||
use Omisai\Continents\Continent; | ||
|
||
it('should return an array of continents', function () { | ||
$collection = new Collection(); | ||
$continents = $collection->getContinents(); | ||
|
||
expect($continents)->toBeArray(); | ||
expect($continents)->toHaveCount(7); | ||
expect($continents[0])->toBeInstanceOf(Continent::class); | ||
}); | ||
|
||
it('should return a continent by code', function () { | ||
$collection = new Collection(); | ||
$continent = $collection->getContinentByCode('AF'); | ||
|
||
expect($continent)->toBeInstanceOf(Continent::class); | ||
expect($continent->code)->toBe('AF'); | ||
}); | ||
|
||
it('should return a continent by name', function () { | ||
$collection = new Collection(); | ||
$continent = $collection->getContinentByName('Africa'); | ||
|
||
expect($continent)->toBeInstanceOf(Continent::class); | ||
expect($continent->name)->toBe('Africa'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
use Omisai\Continents\Continent; | ||
use Omisai\Continents\Models\Europe; | ||
|
||
it('can get the name in English', function () { | ||
$continent = new Europe(); | ||
|
||
expect($continent->getName())->toBe('Europe'); | ||
}); | ||
it('can access the name in English without get', function () { | ||
$continent = new Europe(); | ||
|
||
expect($continent->name)->toBe('Europe'); | ||
}); | ||
|
||
it('can validate a valid locale', function () { | ||
Continent::validate('en'); | ||
})->throwsNoExceptions(); | ||
|
||
it('throws an exception for an invalid locale', function () { | ||
Continent::validate('invalid'); | ||
})->throws(\InvalidArgumentException::class);; | ||
|
||
|
||
it('can access other locale', function () { | ||
$continent = new Europe(); | ||
|
||
expect($continent->getName('hu'))->toBe('Európa'); | ||
expect($continent->getName('es'))->toBe('Europa'); | ||
}); |