public function testSaveBeforeSaveFails() { $input = m::mock('Illuminate\\Http\\Request'); $input->shouldReceive('get')->twice(); $this->config->shouldReceive('validateData')->once()->shouldReceive('getOption')->once()->andReturn(array())->shouldReceive('runBeforeSave')->once()->andReturn('some error')->shouldReceive('putToJson')->never()->shouldReceive('setDataModel')->never(); $field = m::mock('Frozennode\\Administrator\\Fields\\Field'); $field->shouldReceive('getOption')->twice(); $fields = array('field1' => $field, 'field2' => $field); $this->assertEquals($this->config->save($input, $fields), 'some error'); }
public function testSaveValidateFails() { $model = m::mock('stdClass')->makePartial(); $model->exists = false; $model->shouldReceive('find')->once()->shouldReceive('save')->never(); $input = m::mock('Illuminate\\Http\\Request'); $fields = array(); $actionPermissions = array('update' => true, 'create' => true); $this->config->shouldReceive('getDataModel')->twice()->andReturn($model)->shouldReceive('fillModel')->once()->shouldReceive('prepareDataAndRules')->once()->andReturn(array('data' => array(), 'rules' => array()))->shouldReceive('validateData')->once()->andReturn('some error')->shouldReceive('saveRelationships')->never()->shouldReceive('setDataModel')->never(); $this->assertEquals($this->config->save($input, $fields, $actionPermissions), 'some error'); }