1. Go to this page and download the library: Download manageitwa/laravel-fixtures library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
manageitwa / laravel-fixtures example snippets
namespace Fixtures;
use CorpSoft\Fixture\ActiveFixture;
use App\Models\User;
class UserFixture extends ActiveFixture
{
/**
* @var string
*/
public $dataFile = 'fixtures/users.php';
/**
* @var string
*/
public $modelClass = User::class;
}
namespace Fixtures;
use CorpSoft\Fixture\ActiveFixture;
use App\Models\UserProfile;
class UserProfileFixture extends ActiveFixture
{
/**
* @var string
*/
public $dataFile = 'fixtures/user_profile.php';
/**
* @var string
*/
public $modelClass = UserProfile::class;
/**
* @var array
*/
public $depends = [UserFixture::class];
}
namespace Tests;
use CorpSoft\Fixture\Traits\FixtureTrait;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication, FixtureTrait;
/**
* @inheritdoc
*/
protected function setUp()
{
parent::setUp();
$this->initFixtures();
}
}
namespace Tests;
use CorpSoft\Fixture\Traits\FixtureTrait;
use Laravel\Dusk\TestCase as BaseTestCase;
abstract class DuskTestCase extends BaseTestCase
{
use CreatesApplication, FixtureTrait;
/**
* @inheritdoc
*/
protected function setUp()
{
parent::setUp();
$this->initFixtures();
}
// other methods
}
namespace Tests\Unit;
use Tests\TestCase;
use Fixtures\UserProfileFixture;
class ExampleTest extends TestCase
{
/**
* Declares the fixtures that are needed by the current test case.
*
* @return array the fixtures needed by the current test case
*/
public function fixtures(): array
{
return [
'profiles' => UserProfileFixture::class,
];
}
/**
* A basic test example.
*
* @return void
*/
public function testBasicTest()
{
$this->assertTrue(true);
}
}
php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.