Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Model Mockups
  • Hi all, I am new to using fuel php and am wondering if there is a standard in Fuel for creating Model mockups? I currently have the following implementation code that I put together.
     [b]app/classes/model/job.php[/b]
    
    class Model_Job extends Model_Crud {
    
      [b]/** .... snip out all details of this model's properties .... **/[/b]
    
     public function mock()
     {
         $object = new stdClass;
    
         foreach(self::$_properties as $key=>$properties)
         {
             if (!empty($properties['default']))
                 $object->$key = $properties['default'];
         }
    
         $object->deleted = 0;
         
         return $object;
     }
    }
    
    and my test case..
    [b]app/tests/job.php[/b]
    
    class Test_Job extends Fuel\Core\TestCase
    {
       protected function setUp()
       {
          $this->job = Model_Job::mock();
       }
    
       public function test_job_is_not_deleted()
       {
          $expected = 0;
          $this->assertEquals($expected, $this->job->deleted);
       }
    }
    

    I am unsure If I am designing my test cases nicely for fuel, fitting it in with fuel style or I am doing this the hard way?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!