当前位置: 首页>>代码示例>>PHP>>正文


PHP tree::create方法代码示例

本文整理汇总了PHP中tree::create方法的典型用法代码示例。如果您正苦于以下问题:PHP tree::create方法的具体用法?PHP tree::create怎么用?PHP tree::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tree的用法示例。


在下文中一共展示了tree::create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create_data

 /**
  * Seed test data
  */
 public function create_data()
 {
     // bear 1 is named Lawly. She is extremely dangerous. Especially when hungry.
     $bear_lawly = bear::create(['name' => 'Lawly', 'type' => 'Grizzly', 'danger_level' => 8]);
     // bear 2 is named Cerms. He has a loud growl but is pretty much harmless.
     $bear_cerms = bear::create(['name' => 'Cerms', 'type' => 'Black', 'danger_level' => 4]);
     // bear 3 is named Adobot. He is a polar bear.
     $bear_adobot = bear::create(['name' => 'Adobot', 'type' => 'Polar', 'danger_level' => 3]);
     $this->assertInternalType('object', $bear_lawly);
     $this->assertInstanceOf('yf_model_result', $bear_lawly);
     $this->assertInstanceOf('yf_model', $bear_lawly->_get_model());
     $this->assertInstanceOf('bear', $bear_lawly->_get_model());
     $this->assertObjectHasAttribute('id', $bear_lawly);
     $this->assertObjectHasAttribute('name', $bear_lawly);
     $this->assertObjectHasAttribute('type', $bear_lawly);
     $this->assertObjectHasAttribute('danger_level', $bear_lawly);
     $this->assertSame('Lawly', $bear_lawly->name);
     $this->assertSame('Grizzly', $bear_lawly->type);
     $this->assertEquals('8', $bear_lawly->danger_level);
     $this->assertInternalType('object', $bear_cerms);
     $this->assertInstanceOf('yf_model_result', $bear_cerms);
     $this->assertInstanceOf('yf_model', $bear_cerms->_get_model());
     $this->assertInstanceOf('bear', $bear_cerms->_get_model());
     $this->assertObjectHasAttribute('id', $bear_cerms);
     $this->assertObjectHasAttribute('name', $bear_cerms);
     $this->assertObjectHasAttribute('type', $bear_cerms);
     $this->assertObjectHasAttribute('danger_level', $bear_cerms);
     $this->assertSame('Cerms', $bear_cerms->name);
     $this->assertSame('Black', $bear_cerms->type);
     $this->assertEquals('4', $bear_cerms->danger_level);
     $this->assertInternalType('object', $bear_adobot);
     $this->assertInstanceOf('yf_model_result', $bear_adobot);
     $this->assertInstanceOf('yf_model', $bear_adobot->_get_model());
     $this->assertInstanceOf('bear', $bear_adobot->_get_model());
     $this->assertObjectHasAttribute('id', $bear_adobot);
     $this->assertObjectHasAttribute('name', $bear_adobot);
     $this->assertObjectHasAttribute('type', $bear_adobot);
     $this->assertObjectHasAttribute('danger_level', $bear_adobot);
     $this->assertSame('Adobot', $bear_adobot->name);
     $this->assertSame('Polar', $bear_adobot->type);
     $this->assertEquals('3', $bear_adobot->danger_level);
     // seed our fish table. our fish wont have names... because theyre going to be eaten
     // we will use the variables we used to create the bears to get their id
     $fish1 = fish::create(['weight' => '5', 'bear_id' => $bear_lawly->id]);
     $fish2 = fish::create(['weight' => '12', 'bear_id' => $bear_cerms->id]);
     $fish3 = fish::create(['weight' => '4', 'bear_id' => $bear_adobot->id]);
     $this->assertInternalType('object', $fish1);
     $this->assertInstanceOf('yf_model_result', $fish1);
     $this->assertInstanceOf('yf_model', $fish1->_get_model());
     $this->assertInstanceOf('fish', $fish1->_get_model());
     $this->assertObjectHasAttribute('id', $fish1);
     $this->assertObjectHasAttribute('weight', $fish1);
     $this->assertObjectHasAttribute('bear_id', $fish1);
     $this->assertEquals('5', $fish1->weight);
     $this->assertSame($bear_lawly->id, $fish1->bear_id);
     $this->assertInternalType('object', $fish2);
     $this->assertInstanceOf('yf_model_result', $fish2);
     $this->assertInstanceOf('yf_model', $fish2->_get_model());
     $this->assertInstanceOf('fish', $fish2->_get_model());
     $this->assertObjectHasAttribute('id', $fish2);
     $this->assertObjectHasAttribute('weight', $fish2);
     $this->assertObjectHasAttribute('bear_id', $fish2);
     $this->assertEquals('12', $fish2->weight);
     $this->assertSame($bear_cerms->id, $fish2->bear_id);
     $this->assertInternalType('object', $fish3);
     $this->assertInstanceOf('yf_model_result', $fish3);
     $this->assertInstanceOf('yf_model', $fish3->_get_model());
     $this->assertInstanceOf('fish', $fish3->_get_model());
     $this->assertObjectHasAttribute('id', $fish3);
     $this->assertObjectHasAttribute('weight', $fish3);
     $this->assertObjectHasAttribute('bear_id', $fish3);
     $this->assertEquals('4', $fish3->weight);
     $this->assertSame($bear_adobot->id, $fish3->bear_id);
     // seed our trees table
     $tree1 = tree::create(['type' => 'Redwood', 'age' => '500', 'bear_id' => $bear_lawly->id]);
     $tree2 = tree::create(['type' => 'Oak', 'age' => '400', 'bear_id' => $bear_lawly->id]);
     $this->assertInternalType('object', $tree1);
     $this->assertInstanceOf('yf_model_result', $tree1);
     $this->assertInstanceOf('yf_model', $tree1->_get_model());
     $this->assertInstanceOf('tree', $tree1->_get_model());
     $this->assertObjectHasAttribute('id', $tree1);
     $this->assertObjectHasAttribute('type', $tree1);
     $this->assertObjectHasAttribute('age', $tree1);
     $this->assertObjectHasAttribute('bear_id', $tree1);
     $this->assertSame('Redwood', $tree1->type);
     $this->assertEquals('500', $tree1->age);
     $this->assertSame($bear_lawly->id, $tree1->bear_id);
     $this->assertInternalType('object', $tree2);
     $this->assertInstanceOf('yf_model_result', $tree2);
     $this->assertInstanceOf('yf_model', $tree2->_get_model());
     $this->assertInstanceOf('tree', $tree2->_get_model());
     $this->assertObjectHasAttribute('id', $tree2);
     $this->assertObjectHasAttribute('type', $tree2);
     $this->assertObjectHasAttribute('age', $tree2);
     $this->assertObjectHasAttribute('bear_id', $tree2);
     $this->assertSame('Oak', $tree2->type);
     $this->assertEquals('400', $tree2->age);
//.........这里部分代码省略.........
开发者ID:yfix,项目名称:yf,代码行数:101,代码来源:class_model_bears.Test.php


注:本文中的tree::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。