/** * validates the data of a model with the tca definition of a its table. * * @param array $options * only_record_fields: validates only fields included in the record (default) * @return bolean */ public function validateProperties($options = NULL) { return tx_rnbase_util_TCA::validateModel($this, $options === NULL ? array('only_record_fields' => TRUE) : $options); }
/** * is testing th following methods: * tx_rnbase_util_TCA::validateModel(); * tx_rnbase_util_TCA::validateRecord(); * tx_rnbase_model_base::validateProperties(); * * @return void * * @group unit * @test * @dataProvider getValidateModelData */ public function testValidateModel(tx_rnbase_model_base $model, array $options, $valid) { /* @var $options tx_rnbase_model_data */ $options = tx_rnbase::makeInstance('tx_rnbase_model_data', is_array($options) ? $options : array()); // test the tx_rnbase_util_TCA::validateModel method $this->assertEquals($valid, tx_rnbase_util_TCA::validateModel($model, $options)); // test the tx_rnbase_util_TCA::validateRecord method $this->assertEquals($valid, tx_rnbase_util_TCA::validateRecord($model->getProperty(), $model->getTableName(), $options)); // test the tx_rnbase_model_base::validateProperties method $this->assertEquals($valid, $model->validateProperties($options)); if ($valid) { $this->assertFalse($options->hasLastInvalidField(), 'last_invalid_field was set, why?'); $this->assertFalse($options->hasLastInvalidValue(), 'last_invalid_value was set, why?'); } else { $this->assertTrue($options->hasLastInvalidField(), 'last_invalid_field was not set, why?'); // we has to check the property key, // hasLastInvalidValue returns false, if the value is NULL $this->assertTrue(array_key_exists('last_invalid_value', $options->getProperty()), 'last_invalid_value was not set, why?'); } }