本文整理汇总了PHP中Restaurant::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Restaurant::set方法的具体用法?PHP Restaurant::set怎么用?PHP Restaurant::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Restaurant
的用法示例。
在下文中一共展示了Restaurant::set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDeconstructFieldsDateTime
/**
* testDeconstructFields with datetime, timestamp, and date fields
*
* @return void
*/
public function testDeconstructFieldsDateTime()
{
$this->skipIf($this->db instanceof Sqlserver, 'This test is not compatible with SQL Server.');
$this->loadFixtures('Apple');
$TestModel = new Restaurant();
//test null/empty values first
$data['Apple']['created']['year'] = '';
$data['Apple']['created']['month'] = '';
$data['Apple']['created']['day'] = '';
$data['Apple']['created']['hour'] = '';
$data['Apple']['created']['min'] = '';
$data['Apple']['created']['sec'] = '';
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple' => array('created' => ''));
$this->assertEquals($expected, $TestModel->data);
$data = array();
$data['Apple']['date']['year'] = '';
$data['Apple']['date']['month'] = '';
$data['Apple']['date']['day'] = '';
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple' => array('date' => ''));
$this->assertEquals($expected, $TestModel->data);
$data = array();
$data['Apple']['created']['year'] = '2007';
$data['Apple']['created']['month'] = '08';
$data['Apple']['created']['day'] = '20';
$data['Apple']['created']['hour'] = '';
$data['Apple']['created']['min'] = '';
$data['Apple']['created']['sec'] = '';
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple' => array('created' => '2007-08-20 00:00:00'));
$this->assertEquals($expected, $TestModel->data);
$data = array();
$data['Apple']['created']['year'] = '2007';
$data['Apple']['created']['month'] = '08';
$data['Apple']['created']['day'] = '20';
$data['Apple']['created']['hour'] = '10';
$data['Apple']['created']['min'] = '12';
$data['Apple']['created']['sec'] = '';
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple' => array('created' => '2007-08-20 10:12:00'));
$this->assertEquals($expected, $TestModel->data);
$data = array();
$data['Apple']['created']['year'] = '2007';
$data['Apple']['created']['month'] = '';
$data['Apple']['created']['day'] = '12';
$data['Apple']['created']['hour'] = '20';
$data['Apple']['created']['min'] = '';
$data['Apple']['created']['sec'] = '';
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple' => array('created' => ''));
$this->assertEquals($expected, $TestModel->data);
$data = array();
$data['Apple']['created']['hour'] = '20';
$data['Apple']['created']['min'] = '33';
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple' => array('created' => ''));
$this->assertEquals($expected, $TestModel->data);
$data = array();
$data['Apple']['created']['hour'] = '20';
$data['Apple']['created']['min'] = '33';
$data['Apple']['created']['sec'] = '33';
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple' => array('created' => ''));
$this->assertEquals($expected, $TestModel->data);
$data = array();
$data['Apple']['created']['hour'] = '13';
$data['Apple']['created']['min'] = '00';
$data['Apple']['date']['year'] = '2006';
$data['Apple']['date']['month'] = '12';
$data['Apple']['date']['day'] = '25';
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple' => array('created' => '', 'date' => '2006-12-25'));
$this->assertEquals($expected, $TestModel->data);
$data = array();
$data['Apple']['created']['year'] = '2007';
$data['Apple']['created']['month'] = '08';
$data['Apple']['created']['day'] = '20';
$data['Apple']['created']['hour'] = '10';
$data['Apple']['created']['min'] = '12';
$data['Apple']['created']['sec'] = '09';
$data['Apple']['date']['year'] = '2006';
$data['Apple']['date']['month'] = '12';
$data['Apple']['date']['day'] = '25';
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple' => array('created' => '2007-08-20 10:12:09', 'date' => '2006-12-25'));
//.........这里部分代码省略.........
示例2: testBehaviorMethodDispatchingWithData
/**
* testBehaviorMethodDispatchingWithData method
*
* @return void
*/
public function testBehaviorMethodDispatchingWithData()
{
$Apple = new Restaurant();
$Apple->Behaviors->load('Test');
$Apple->set('field', 'value');
$this->assertTrue($Apple->testData());
$this->assertTrue($Apple->data['Apple']['field_2']);
$this->assertTrue($Apple->testData('one', 'two', 'three', 'four', 'five', 'six'));
}