PHP code example of celtric / fixtures

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

    

celtric / fixtures example snippets




namespace Foo\Bar;

class Person
{
    private $name;
    private $age;

    public function __construct($name, $age)
    {
        $this->name = $name;
        $this->age = $age;
    }
}



namespace Tests;

class FooTest extends \PHPUnit_Framework_TestCase
{
    /** @test */
    public function can_load_fixtures()
    {
        $this->assertEquals(new Person("Ricard", 30), $this->fixture("people.ricard"));
    }
    
    /**
     * @param string $fixtureName
     * @return mixed
     */
    private function fixture($fixtureName)
    {
        $fixtures = Fixtures::celtricStyle(__DIR__ . "/../fixtures/");
        
        return $fixtures->fixture($fixtureName);
    }
}



namespace Foo\Bar;

class Money
{
    private $amount;
    private $currency;

    public function __construct($amount, Currency $currency)
    {
        $this->amount = $amount;
        $this->currency = $currency;
    }
}

class Currency
{
    private $isoCode;

    public function __construct($isoCode)
    {
        $this->isoCode = $isoCode;
    }
}