本文整理汇总了PHP中Category_Model::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Category_Model::validate方法的具体用法?PHP Category_Model::validate怎么用?PHP Category_Model::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Category_Model
的用法示例。
在下文中一共展示了Category_Model::validate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testValidate
/**
* Tests the validate() method in Category_Model
*
* @test
* @dataProvider providerValidate
* @param array $valid Valid data for the test
* @param array $invalid Invalid data for the test
* @param array $save Saves the record when validation succeeds
*/
public function testValidate($valid, $invalid, $save)
{
// Model instance for the test
$category = new Category_Model();
// Valid data test
$this->assertEquals(TRUE, $category->validate($valid, $save));
// Invalid data test
$this->assertEquals(FALSE, $category->validate($invalid, $save));
}
示例2: testValidate
/**
* Tests the validate() method in Category_Model
*
* @test
* @dataProvider providerValidate
* @param array $valid Valid data for the test
* @param array $invalid Invalid data for the test
* @param array $save Saves the record when validation succeeds
*/
public function testValidate($valid, $invalid, $invalid2, $specialsub, $save)
{
// Model instance for the test on a new category
$category = new Category_Model();
// Model instance for the test on an existing special category
$special_sub = new Category_Model(testutils::get_random_id('category', 'WHERE category_trusted = 1'));
// Valid data test
$this->assertEquals(TRUE, $category->validate($valid, $save));
// Invalid data test 1
$this->assertEquals(FALSE, $category->validate($invalid, $save));
// Invalid data test 2
$this->assertEquals(FALSE, $category->validate($invalid2, $save));
// Invalid data test 3
$this->assertEquals(FALSE, $special_sub->validate($specialsub, $save));
}
示例3: save_category
/**
* Save newly added dynamic categories
*/
public function save_category()
{
$this->auto_render = FALSE;
$this->template = "";
// Check, has the form been submitted, if so, setup validation
if ($_POST) {
// Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things
// HT: New code for category save with parent
$post = arr::extract($_POST, 'parent_id', 'category_title', 'category_description', 'category_color');
// Category instance for the operation
$category = new Category_Model();
if ($category->validate($post)) {
$category->save();
$form_saved = TRUE;
echo json_encode(array("status" => "saved", "id" => $category->id));
} else {
echo json_encode(array("status" => "error"));
}
} else {
echo json_encode(array("status" => "error"));
}
}