ardent icon indicating copy to clipboard operation
ardent copied to clipboard

Unable to unit test:

Open bkuhl opened this issue 10 years ago • 3 comments

Is Ardent testable? It seems like I'm not doing anything special here and it's throwing a fatal error

My model:

class Account extends \LaravelBook\Ardent\Ardent
{

    protected $fillable = ['name', 'description', 'number'];

    /** @var [] Form validation rules */
    public static $rules = [
        'name'  => 'required|between:1,45',
        'description' => 'between:1,128',
        'number' => 'between:1,30'
    ];

}

My test:

<?php

use Codeception\Util\Stub;

class AccountModelTest extends \Codeception\TestCase\Test
{
   /**
    * @var \CodeGuy
    */
    protected $codeGuy;

    protected function _before()
    {
        $this->account = new Account();
    }

    protected function _after()
    {
    }

    /**
     * Test form validation
     */
    public function testAccountValidation()
    {
        //check name validation
        $this->assertFalse($this->account->validate());

        $this->account->name = \Faker\Provider\Lorem::text(46);
        $this->assertFalse($this->account->validate());

        $this->account->name = \Faker\Provider\Lorem::text(32);
        $this->assertTrue($this->account->validate());

        //check description validation
        $this->account->description = \Faker\Provider\Lorem::text(129);
        $this->assertFalse($this->account->validate());

        $this->account->description = \Faker\Provider\Lorem::text(64);
        $this->assertTrue($this->account->validate());

        //check number validation
        $this->account->number = \Faker\Provider\Lorem::text(31);
        $this->assertFalse($this->account->validate());

        $this->account->number = \Faker\Provider\Lorem::text(24);
        $this->assertTrue($this->account->validate());
    }

}```

The error:

Unit Tests (1) ------------------------------------------------------------------------ Trying to test account validation (AccountModelTest::testAccountValidation) PHP Fatal error: Call to a member function make() on a non-object in /Users/.../vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 214```

bkuhl avatar Jan 13 '14 21:01 bkuhl

I am also experiencing this issue.

rogue780 avatar May 05 '14 00:05 rogue780

I've stopped using Ardent and gone a different direction with our architecture.

bkuhl avatar May 05 '14 00:05 bkuhl

Yeah, we've abandoned Ardent as well and implemented the features we wanted in our own model.

rogue780 avatar May 05 '14 17:05 rogue780