/**
  * @test
  */
 public function modelBadRequestTest()
 {
     $controller = new BaseController();
     $model = new BaseModel();
     $model->appendMessage(new Message('name is required'));
     $this->assertEquals(self::HTTP_CODE_400, $controller->modelBadRequest($model, [])->getStatusCode());
 }
 public function load()
 {
     $file = file_get_contents(__DIR__ . '/data/base_model.json');
     $fileData = json_decode($file);
     foreach ($fileData as $data) {
         $entity = new BaseModel();
         $save = $entity->save();
         if (!$save) {
             throw new \Exception('Save fail: ' . implode("\n", $entity->getMessages()));
         }
     }
 }
 /**
  * @test
  */
 public function findTest()
 {
     $this->createTest();
     $this->createTest();
     $this->createTest();
     $models = BaseModel::find();
     $this->assertNotEmpty($models);
     $this->assertEquals(3, count($models));
 }
 /**
  * @test
  * @fixture("BaseModel")
  */
 public function truncateTest()
 {
     $unitTestCase = new TestCase();
     $unitTestCase->setUp($this->di, $this->config);
     $this->assertEquals(4, BaseModel::count());
     $truncate = $unitTestCase->truncateTables($this->di->getDb());
     $this->assertInstanceOf('Phalcon\\Test\\UnitTestCase', $truncate);
     $this->assertEquals(0, BaseModel::count());
     $unitTestCase->__destruct();
 }
Example #5
0
 /**
  * Define column map
  * @return array
  */
 public function columnMap()
 {
     return array_merge(parent::columnMap(), ['name' => 'name', 'user_id' => 'user']);
 }