-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from SuperDJ/dev-tests
Added tests
- Loading branch information
Showing
30 changed files
with
1,045 additions
and
162 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,9 @@ | ||
/.editorconfig export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.github export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/tests export-ignore | ||
/CHANGELOG.md export-ignore | ||
/CONTRIBUTING.md export-ignore | ||
/README.md export-ignore |
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,41 @@ | ||
name: Tests | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [master, main] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php: [7.2, 7.3, 7.4, 8.0, 8.1] | ||
stability: [prefer-lowest, prefer-stable] | ||
|
||
name: PHP ${{ matrix.php }} - ${{ matrix.stability }} Test | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: dom, curl, libxml, mbstring, zip, pdo | ||
ini-values: error_reporting=E_ALL | ||
tools: composer:v2 | ||
coverage: none | ||
|
||
- name: Install dependencies | ||
uses: nick-invision/retry@v1 | ||
with: | ||
timeout_minutes: 5 | ||
max_attempts: 5 | ||
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress | ||
|
||
- name: Run tests | ||
run: ./vendor/bin/phpunit | ||
vendor/bin/phpunit --verbose |
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,3 @@ | ||
/vendor | ||
composer.lock | ||
*.cache |
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,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
bootstrap="./vendor/autoload.php" | ||
colors="true" | ||
verbose="true" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd" | ||
> | ||
<testsuites> | ||
<testsuite name="Unit"> | ||
<directory suffix="Test.php">./tests/Unit</directory> | ||
</testsuite> | ||
<testsuite name="Feature"> | ||
<directory suffix="Test.php">./tests/Feature</directory> | ||
</testsuite> | ||
</testsuites> | ||
<coverage processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
</coverage> | ||
<php> | ||
<ini name="display_errors" value="On" /> | ||
<ini name="display_startup_errors" value="On" /> | ||
<ini name="date.timezone" value="UTC" /> | ||
<ini name="intl.default_locale" value="C.UTF-8" /> | ||
<ini name="memory_limit" value="2048M" /> | ||
<env name="DB_CONNECTION" value="sqlite" /> | ||
<env name="DB_DATABASE" value=":memory:" /> | ||
<env name="APP_KEY" value="base64:2fl+Ktvkfl+Fuz4Qp/A75G2RTiWVA/ZoKZvp6fiiM10="/> | ||
</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
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,19 @@ | ||
<?php | ||
|
||
namespace AjCastro\EagerLoadPivotRelations\Tests\Database\Factories; | ||
|
||
use AjCastro\EagerLoadPivotRelations\Tests\Models\Brand; | ||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
||
class BrandFactory extends Factory | ||
{ | ||
protected $model = Brand::class; | ||
|
||
public function definition() | ||
{ | ||
return [ | ||
'name' => $this->faker->word, | ||
'logo' => $this->faker->imageUrl, | ||
]; | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
namespace AjCastro\EagerLoadPivotRelations\Tests\Database\Factories; | ||
|
||
use AjCastro\EagerLoadPivotRelations\Tests\Models\Brand; | ||
use AjCastro\EagerLoadPivotRelations\Tests\Models\Car; | ||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
||
/** | ||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\AjCastro\EagerLoadPivotRelations\Tests\Models\Car> | ||
*/ | ||
class CarFactory extends Factory | ||
{ | ||
protected $model = Car::class; | ||
|
||
public function definition() | ||
{ | ||
return [ | ||
'model' => $this->faker->words(rand(2, 4), true), | ||
'brand_id' => function() | ||
{ | ||
return Brand::factory()->create()->id; | ||
} | ||
]; | ||
} | ||
} |
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 @@ | ||
<?php | ||
|
||
namespace AjCastro\EagerLoadPivotRelations\Tests\Database\Factories; | ||
|
||
use AjCastro\EagerLoadPivotRelations\Tests\Models\Car; | ||
use AjCastro\EagerLoadPivotRelations\Tests\Models\CarUser; | ||
use AjCastro\EagerLoadPivotRelations\Tests\Models\Color; | ||
use AjCastro\EagerLoadPivotRelations\Tests\Models\Tire; | ||
use AjCastro\EagerLoadPivotRelations\Tests\Models\User; | ||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
||
/** | ||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\AjCastro\EagerLoadPivotRelations\Tests\Models\CarUser> | ||
*/ | ||
class CarUserFactory extends Factory | ||
{ | ||
protected $model = CarUser::class; | ||
|
||
public function definition() | ||
{ | ||
return [ | ||
'car_id' => function() { | ||
return Car::factory()->create()->id; | ||
}, | ||
'color_id' => function() { | ||
return Color::factory()->create()->id; | ||
}, | ||
'user_id' => function() { | ||
return User::factory()->create()->id; | ||
} | ||
]; | ||
} | ||
} |
Oops, something went wrong.