-
Notifications
You must be signed in to change notification settings - Fork 8
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
df0f9c6
commit a896a10
Showing
7 changed files
with
157 additions
and
3 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 |
---|---|---|
|
@@ -4,7 +4,6 @@ build | |
composer.lock | ||
coverage | ||
docs | ||
phpunit.xml | ||
phpstan.neon | ||
testbench.yaml | ||
vendor | ||
|
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
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,21 @@ | ||
<?php | ||
|
||
namespace Database\Seeders; | ||
|
||
use Illuminate\Database\Seeder; | ||
|
||
class DatabaseSeeder extends Seeder | ||
{ | ||
/** | ||
* Seed the application's database. | ||
* | ||
* @return void | ||
*/ | ||
public function run() | ||
{ | ||
$this->call([ | ||
WilayaSeeder::class, | ||
DairaSeeder::class, | ||
]); | ||
} | ||
} |
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,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
bootstrap="vendor/autoload.php" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
verbose="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" | ||
> | ||
<coverage> | ||
<include> | ||
<directory suffix=".php">src/</directory> | ||
</include> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="Unit"> | ||
<directory suffix="Test.php">./tests/Unit</directory> | ||
</testsuite> | ||
<testsuite name="Feature"> | ||
<directory suffix="Test.php">./tests/Feature</directory> | ||
</testsuite> | ||
</testsuites> | ||
<php> | ||
<env name="DB_CONNECTION" value="testing"/> | ||
<env name="APP_KEY" value="base64:USGB1pG+heJfX9iwg5MNrpNWFOYVv+TM3LaTDGt6iDw="/> | ||
</php> | ||
</phpunit> |
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,36 @@ | ||
<?php | ||
|
||
namespace TheHocineSaad\LaravelAlgereography\Tests; | ||
|
||
use Illuminate\Support\Facades\Artisan; | ||
use Illuminate\Support\Facades\Schema; | ||
use TheHocineSaad\LaravelAlgereography\LaravelAlgereographyServiceProvider; | ||
|
||
class TestCase extends \Orchestra\Testbench\TestCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
} | ||
|
||
protected function getPackageProviders($app) | ||
{ | ||
return [ | ||
LaravelAlgereographyServiceProvider::class, | ||
]; | ||
} | ||
|
||
protected function getEnvironmentSetUp($app) | ||
{ | ||
Schema::hasTable('wilayas') ?? Schema::drop('wilayas'); | ||
Schema::hasTable('dairas') ?? Schema::drop('dairas'); | ||
|
||
$migration = include __DIR__.'/../database/migrations/1999_03_11_000000_create_wilayas_table.php'; | ||
$migration->up(); | ||
|
||
$migration = include __DIR__.'/../database/migrations/1999_03_11_000001_create_dairas_table.php'; | ||
$migration->up(); | ||
|
||
Artisan::call('db:seed'); | ||
} | ||
} |
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,32 @@ | ||
<?php | ||
|
||
namespace TheHocineSaad\LaravelAlgereography\Tests\Unit; | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use TheHocineSaad\LaravelAlgereography\Models\Daira; | ||
use TheHocineSaad\LaravelAlgereography\Models\Wilaya; | ||
use TheHocineSaad\LaravelAlgereography\Tests\TestCase; | ||
|
||
class DairaTest extends TestCase | ||
{ | ||
public function test_if_dairas_table_is_created() | ||
{ | ||
$this->assertTrue(Schema::hasTable('dairas')); | ||
} | ||
|
||
public function test_if_dairas_table_has_all_columns() | ||
{ | ||
$this->assertTrue(Schema::hasColumns('dairas', ['id', 'name', 'ar_name', 'wilaya_id'])); | ||
} | ||
|
||
public function test_if_all_dairas_exists() | ||
{ | ||
$this->assertDatabaseCount('dairas', 548); | ||
} | ||
|
||
public function test_if_relationship_with_wilayas_is_working() | ||
{ | ||
$daira = Daira::find(1); | ||
$this->assertInstanceOf(Wilaya::class, $daira->wilaya); | ||
} | ||
} |
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 | ||
|
||
namespace TheHocineSaad\LaravelAlgereography\Tests\Unit; | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use TheHocineSaad\LaravelAlgereography\Models\Wilaya; | ||
use TheHocineSaad\LaravelAlgereography\Tests\TestCase; | ||
|
||
class WilayaTest extends TestCase | ||
{ | ||
public function test_if_wilayas_table_is_created() | ||
{ | ||
$this->assertTrue(Schema::hasTable('wilayas')); | ||
} | ||
|
||
public function test_if_wilayas_table_has_all_columns() | ||
{ | ||
$this->assertTrue(Schema::hasColumns('wilayas', ['id', 'name', 'ar_name'])); | ||
} | ||
|
||
public function test_if_all_wilayas_exists() | ||
{ | ||
$this->assertDatabaseCount('wilayas', 58); | ||
} | ||
|
||
public function test_if_relationship_with_dairas_is_working() | ||
{ | ||
$wilaya = Wilaya::find(1); | ||
$this->assertInstanceOf('Illuminate\Database\Eloquent\Collection', $wilaya->dairas); | ||
} | ||
} |