當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Restaurant::set方法代碼示例

本文整理匯總了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'));
//.........這裏部分代碼省略.........
開發者ID:nogikko,項目名稱:yumyum,代碼行數:101,代碼來源:ModelIntegrationTest.php

示例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'));
 }
開發者ID:nogikko,項目名稱:yumyum,代碼行數:14,代碼來源:BehaviorCollectionTest.php


注:本文中的Restaurant::set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。