protected function _executeTestsNormal($di) { $robot = new Robots(); $success = $robot->save(array('type' => 'mechanical', 'year' => 2018)); $this->assertEquals($success, false); $this->assertEquals($robot->type, 'mechanical'); $this->assertEquals($robot->year, 2018); $robot = new Robots(); $robot->assign(array('type' => 'mechanical', 'year' => 2018)); $this->assertEquals($robot->type, 'mechanical'); $this->assertEquals($robot->year, 2018); //not assigns nonexistent fields $robot = new Robots(); $robot->assign(array('field1' => 'mechanical', 'field2' => 2018)); $this->assertEquals(empty($robot->field1), true); $this->assertEquals(empty($robot->field2), true); //white list $robot = new Robots(); $robot->assign(array('type' => 'mechanical', 'year' => 2018), null, array('type')); $this->assertEquals($robot->type, 'mechanical'); $this->assertEquals(empty($robot->year), true); //white list $robot = new Robots(); $robot->assign(array('typeFromClient' => 'mechanical', 'yearFromClient' => 2018), array('typeFromClient' => 'type', 'yearFromClient' => 'year'), array('type')); $this->assertEquals($robot->type, 'mechanical'); $this->assertEquals(empty($robot->year), true); }
protected function _executeTestsNormal($di) { $robot = new Robots(); $success = $robot->save(array('type' => 'mechanical', 'year' => 2018)); $this->assertEquals($success, false); $this->assertEquals($robot->type, 'mechanical'); $this->assertEquals($robot->year, 2018); $robot = new Robots(); $robot->assign(array('type' => 'mechanical', 'year' => 2018)); $this->assertEquals($robot->type, 'mechanical'); $this->assertEquals($robot->year, 2018); }