PHP code example of rnr / laravel-alice

1. Go to this page and download the library: Download rnr/laravel-alice 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/ */

    

rnr / laravel-alice example snippets



namespace Rnr\Tests\Alice;

use Orchestra\Testbench\TestCase as ParentTestCase;
use Rnr\Alice\FixturesLoader;
use Nelmio\Entity\User;
use Nelmio\Entity\Group;

class TestCase extends ParentTestCase
{
    /** @var FixturesLoader */
    protected $fixturesLoader;

    protected function setUp()
    {
        parent::setUp();

        $this->fixturesLoader = $this->app->make(FixturesLoader::class);
    }
    
    public function testLoadingFixtures() {
        $objects = $this->fixturesLoader->load('fixture.yml');
        
        $users = User::all();
        
        $this->assertEquals(array_map($objects, function ($model) {
            return $model->getKey();
        }), $users->modelKeys());
    }
}


namespace Nelmio\Entity;

use Illuminate\Database\Eloquent\Model;

class User extends Model  {
    protected $table = 'users';
}

class Group extends Model {
    protected $table = 'groups';
    
    public function owner() {
        return $this->belnogsTo(User::class);
    }
}