Skip to content

Commit

Permalink
Merge pull request #7 from biiiiiigmonster/phpunit
Browse files Browse the repository at this point in the history
Phpunit
  • Loading branch information
biiiiiigmonster authored Sep 1, 2022
2 parents 545be6a + 0dc9f2d commit 082381e
Show file tree
Hide file tree
Showing 54 changed files with 1,217 additions and 4 deletions.
17 changes: 17 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore all test and documentation with "export-ignore".
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/phpunit.xml export-ignore
/art export-ignore
/database export-ignore
/docs export-ignore
/tests export-ignore
/.editorconfig export-ignore
/psalm.xml export-ignore
/psalm.xml.dist export-ignore
/testbench.yaml export-ignore
/UPGRADING.md export-ignore
11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/vendor/
.idea
/composer.lock
.phpunit.result.cache
build
composer.lock
coverage
docs
phpunit.xml
testbench.yaml
vendor
node_modules
5 changes: 5 additions & 0 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ Image::hasMorphIn('imageable', [Post::class, Comment::class])->get();
User::hasIn('posts.comments')->get();
```

## 测试
```bash
composer test
```

## 联系交流
wx:biiiiiigmonster(备注:hasin)

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,10 @@ Image::hasMorphIn('imageable', [Post::class, Comment::class])->get();
User::hasIn('posts.comments')->get();
```

# Testing
```bash
composer test
```

# License
[MIT](./LICENSE)
19 changes: 17 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,22 @@
"laravel/framework": "^9"
},
"require-dev": {
"laravel/pint": "^1.1"
"laravel/pint": "^1.1",
"phpunit/phpunit": "^9",
"orchestra/testbench": "^7.7",
"pestphp/pest": "^1.22",
"pestphp/pest-plugin-laravel": "^1.2"
},
"autoload": {
"psr-4": {
"BiiiiiigMonster\\Hasin\\": "src/"
"BiiiiiigMonster\\Hasin\\": "src",
"BiiiiiigMonster\\Hasin\\Database\\Factories\\": "database/factories",
"Database\\Seeders\\": "database/seeders"
}
},
"autoload-dev": {
"psr-4": {
"BiiiiiigMonster\\Hasin\\Tests\\": "tests"
}
},
"extra": {
Expand All @@ -27,5 +38,9 @@
"BiiiiiigMonster\\Hasin\\HasinServiceProvider"
]
}
},
"scripts": {
"test": "vendor/bin/pest",
"format": "vendor/bin/pint"
}
}
24 changes: 24 additions & 0 deletions database/factories/CommentFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace BiiiiiigMonster\Hasin\Database\Factories;

use BiiiiiigMonster\Hasin\Tests\Models\Comment;
use Illuminate\Database\Eloquent\Factories\Factory;

class CommentFactory extends Factory
{
protected $model = Comment::class;

/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'content' => $this->faker->sentence,
'status' => $this->faker->numberBetween(0, 9),
];
}
}
23 changes: 23 additions & 0 deletions database/factories/CountryFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace BiiiiiigMonster\Hasin\Database\Factories;

use BiiiiiigMonster\Hasin\Tests\Models\Country;
use Illuminate\Database\Eloquent\Factories\Factory;

class CountryFactory extends Factory
{
protected $model = Country::class;

/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->country
];
}
}
23 changes: 23 additions & 0 deletions database/factories/HistoryFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace BiiiiiigMonster\Hasin\Database\Factories;

use BiiiiiigMonster\Hasin\Tests\Models\History;
use Illuminate\Database\Eloquent\Factories\Factory;

class HistoryFactory extends Factory
{
protected $model = History::class;

/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'content' => $this->faker->address
];
}
}
23 changes: 23 additions & 0 deletions database/factories/ImageFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace BiiiiiigMonster\Hasin\Database\Factories;

use BiiiiiigMonster\Hasin\Tests\Models\Image;
use Illuminate\Database\Eloquent\Factories\Factory;

class ImageFactory extends Factory
{
protected $model = Image::class;

/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'url' => $this->faker->url
];
}
}
23 changes: 23 additions & 0 deletions database/factories/PhoneFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace BiiiiiigMonster\Hasin\Database\Factories;

use BiiiiiigMonster\Hasin\Tests\Models\Phone;
use Illuminate\Database\Eloquent\Factories\Factory;

class PhoneFactory extends Factory
{
protected $model = Phone::class;

/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'phone_number' => $this->faker->phoneNumber
];
}
}
24 changes: 24 additions & 0 deletions database/factories/PostFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace BiiiiiigMonster\Hasin\Database\Factories;

use BiiiiiigMonster\Hasin\Tests\Models\Post;
use Illuminate\Database\Eloquent\Factories\Factory;

class PostFactory extends Factory
{
protected $model = Post::class;

/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'title' => $this->faker->title,
'votes' => $this->faker->numberBetween(0, 100),
];
}
}
23 changes: 23 additions & 0 deletions database/factories/RoleFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace BiiiiiigMonster\Hasin\Database\Factories;

use BiiiiiigMonster\Hasin\Tests\Models\Role;
use Illuminate\Database\Eloquent\Factories\Factory;

class RoleFactory extends Factory
{
protected $model = Role::class;

/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->name
];
}
}
23 changes: 23 additions & 0 deletions database/factories/SupplierFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace BiiiiiigMonster\Hasin\Database\Factories;

use BiiiiiigMonster\Hasin\Tests\Models\Supplier;
use Illuminate\Database\Eloquent\Factories\Factory;

class SupplierFactory extends Factory
{
protected $model = Supplier::class;

/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->name
];
}
}
23 changes: 23 additions & 0 deletions database/factories/TagFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace BiiiiiigMonster\Hasin\Database\Factories;

use BiiiiiigMonster\Hasin\Tests\Models\Tag;
use Illuminate\Database\Eloquent\Factories\Factory;

class TagFactory extends Factory
{
protected $model = Tag::class;

/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->name
];
}
}
24 changes: 24 additions & 0 deletions database/factories/UserFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace BiiiiiigMonster\Hasin\Database\Factories;

use BiiiiiigMonster\Hasin\Tests\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

class UserFactory extends Factory
{
protected $model = User::class;

/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'username' => $this->faker->userName,
'age' => $this->faker->numberBetween(10, 30),
];
}
}
23 changes: 23 additions & 0 deletions database/factories/VideoFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace BiiiiiigMonster\Hasin\Database\Factories;

use BiiiiiigMonster\Hasin\Tests\Models\Video;
use Illuminate\Database\Eloquent\Factories\Factory;

class VideoFactory extends Factory
{
protected $model = Video::class;

/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->name
];
}
}
Loading

0 comments on commit 082381e

Please sign in to comment.