本文整理汇总了PHP中Jam::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Jam::create方法的具体用法?PHP Jam::create怎么用?PHP Jam::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jam
的用法示例。
在下文中一共展示了Jam::create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_set
/**
* Integration test for:
* - Kohana_Jam_Behavior_Sortable::model_before_create
* - Kohana_Jam_Behavior_Sortable::builder_call_where_in_scope
* - Kohana_Jam_Behavior_Sortable::model_call_get_position
*
* @coversNothing
*/
public function test_set()
{
$last_in_group = Jam::all('test_video')->where('group', '=', 'one')->first();
$new = Jam::create('test_video', array('file' => 'file3.jpg', 'group' => 'one'));
$first_in_group = Jam::create('test_video', array('file' => 'file3.jpg', 'group' => 'nogroup'));
$this->assertGreaterThan($last_in_group->position, $new->position);
$this->assertEquals(1, $first_in_group->position);
}
示例2: test_builder_method_with_terms
/**
* @covers Jam_Behavior_Taxonomable::builder_call_with_terms
*/
public function test_builder_method_with_terms()
{
Jam::create('taxonomy_event', array('name' => 'abc', 'terms' => array(array('id' => 100, 'name' => 'poiuy', 'slug' => 'poiuy', 'vocabulary' => 1))));
Jam::create('taxonomy_event', array('name' => 'xyz', 'terms' => array(array('id' => 101, 'name' => 'qwerty', 'slug' => 'qwerty', 'vocabulary' => 1))));
$builder = Jam::all('taxonomy_event');
$this->assertEquals('SELECT `taxonomy_events`.* FROM `taxonomy_events`', $builder);
$builder->with_terms('qwerty');
$this->assertEquals("SELECT `taxonomy_events`.* FROM `taxonomy_events` JOIN `terms_items` AS `terms-101` ON (`terms-101`.`item_id` = `taxonomy_events`.`id` AND `terms-101`.`item_model` = 'taxonomy_event' AND `terms-101`.`term_id` IN (101))", (string) $builder);
$builder->reset();
$builder->with_terms('poiuy');
$this->assertEquals("SELECT `taxonomy_events`.* FROM `taxonomy_events` JOIN `terms_items` AS `terms-100` ON (`terms-100`.`item_id` = `taxonomy_events`.`id` AND `terms-100`.`item_model` = 'taxonomy_event' AND `terms-100`.`term_id` IN (100))", (string) $builder);
$builder->reset();
$builder->with_terms(array('qwerty', 'poiuy'));
$this->assertEquals("SELECT `taxonomy_events`.* FROM `taxonomy_events` JOIN `terms_items` AS `terms-100-101` ON (`terms-100-101`.`item_id` = `taxonomy_events`.`id` AND `terms-100-101`.`item_model` = 'taxonomy_event' AND `terms-100-101`.`term_id` IN (100,101))", (string) $builder);
$builder->reset();
$builder->with_terms(array('qwerty', 'poiuy'), 'NOT IN');
$this->assertEquals("SELECT `taxonomy_events`.* FROM `taxonomy_events` JOIN `terms_items` AS `terms-100-101` ON (`terms-100-101`.`item_id` = `taxonomy_events`.`id` AND `terms-100-101`.`item_model` = 'taxonomy_event' AND `terms-100-101`.`term_id` NOT IN (100,101))", (string) $builder);
$builder->reset();
$builder->with_terms('poiusadsfdsfy');
// Missing slugs are completely ignored and do not limit the query
$this->assertEquals("SELECT `taxonomy_events`.* FROM `taxonomy_events`", (string) $builder);
}
示例3: test_shallow
/**
* @covers Kohana_Jam_Association_Materializedpath_Hasmany::save
* @covers Kohana_Jam_Association_Materializedpath_Hasmany::model_after_delete
*/
public function test_shallow()
{
$nine = Jam::create('category', array('name' => 'nine'));
$four = Jam::find('category', 4);
$four->children->add($nine);
$four->save();
$one = Jam::find('category', 1);
$two = Jam::find('category', 2);
$four = Jam::find('category', 4);
$this->assertTrue($nine->is_decendent_of($one));
$this->assertTrue($nine->is_decendent_of($two));
$this->assertTrue($nine->is_decendent_of($four));
$seven = Jam::find('category', 7);
$seven->parent = $nine;
$seven->save();
$this->assertTrue($seven->is_decendent_of($nine));
$this->assertTrue($seven->is_decendent_of($two));
$this->assertTrue($seven->is_decendent_of($one));
$this->assertTrue($seven->is_decendent_of($four));
$this->assertTrue($nine->children->has($seven));
$nine->delete();
$this->assertEquals(array(2, 3, 4, 5, 6, 8), $one->decendents()->ids());
}
示例4: array
<?php
$role_login = Jam::create('test_role', array('name' => 'login', 'description' => 'Login Permssion'));
$role_admin = Jam::create('test_role', array('name' => 'admin', 'description' => 'Admin Permssion'));
$user1 = Jam::create('test_user', array('id' => '1', 'email' => 'admin@example.com', 'username' => 'admin', 'password' => 'qweqwe', 'logins' => '5', 'last_login' => strtotime('last month'), 'last_login_ip' => '10.20.10.1', 'facebook_uid' => 'facebook-test', 'roles' => array($role_login), 'user_tokens' => array(array('id' => 1, 'user_agent' => '92b1e2f536fa11fa996731b98b219f837d4436c8', 'token' => '4c14538f3c4a3b8cf30086958911d0d0ae1b2eb7', 'created' => strtotime('last week'), 'expires' => strtotime('tomorrow')), array('id' => 3, 'user_agent' => '92b1e2f536fa11fa996731b98b219f837d4436c8', 'token' => '59ed73c1a3c105e7409c69c21770d674949c07e9', 'created' => strtotime('last month'), 'expires' => strtotime('last week')))));
$user2 = Jam::create('test_user', array('id' => '2', 'email' => 'user@example.com', 'username' => 'user', 'password' => 'qweqwe', 'logins' => '20', 'last_login' => strtotime('last week'), 'last_login_ip' => '10.20.10.2', 'roles' => array($role_login, $role_admin), 'user_tokens' => array(array('id' => 2, 'user_agent' => '92b1e2f536fa11fa996731b98b219f837d4436c8', 'token' => 'f0dc12b77cf0214fbd04e2a224422f44adc7652c', 'created' => strtotime('last week'), 'expires' => strtotime('tomorrow')))));
示例5: test_before_create
public function test_before_create()
{
$video = Jam::create('test_video', array('file' => 'test.mp4'));
$this->assertNotNull($video->token);
}
示例6: test_mass_children
public function test_mass_children()
{
$n1 = Jam::create('test_closurelist', array('name' => 'n1', 'children' => array(array('name' => 'n2', 'children' => array(array('name' => 'n3'))))));
$this->assertEquals('n1', $n1->name());
$this->assertCount(1, $n1->children);
$this->assertEquals('n2', $n1->children[0]->name());
$this->assertCount(1, $n1->children[0]->children);
$this->assertEquals('n3', $n1->children[0]->children[0]->name());
$n1 = Jam::find('test_closurelist', 'n1');
$this->assertEquals('n1', $n1->name());
$this->assertCount(1, $n1->children);
$this->assertEquals('n2', $n1->children[0]->name());
$this->assertCount(1, $n1->children[0]->children);
$this->assertEquals('n3', $n1->children[0]->children[0]->name());
}
示例7: array
$post1 = Jam::create('test_post', array('id' => 1, 'name' => 'First Post', 'slug' => 'first-post', 'status' => 'draft', 'created' => 1264985737, 'updated' => 1264985737, 'published' => 1264985737, 'test_author' => $author1, 'test_blog' => $blog1, 'test_categories' => array(1, 2, 3)));
$post2 = Jam::create('test_post', array('id' => 2, 'name' => 'Second Post', 'slug' => 'first-post', 'status' => 'review', 'created' => 1264985737, 'updated' => 1264985740, 'published' => 1264985737, 'test_author' => $author1, 'test_blog' => $blog3, 'approved_by' => $author1, 'test_categories' => array(2)));
$post3 = Jam::create('test_post', array('id' => 3, 'name' => 'Third Post', 'slug' => 'third-post', 'status' => 'draft', 'created' => 1264985737, 'updated' => 1264985740, 'published' => 1264985737));
/**
* Tags
*/
Jam::create('test_tag', array('id' => 1, 'name' => 'red', 'slug' => 'red', 'test_post' => $post1, 'test_blogs' => array($blog1)));
Jam::create('test_tag', array('id' => 2, 'name' => 'green', 'slug' => 'green', 'test_post' => $post1, 'test_blogs' => array($blog1)));
Jam::create('test_tag', array('id' => 3, 'name' => 'orange', 'slug' => 'orange', 'test_post' => $post2, 'test_blogs' => array($blog2)));
Jam::create('test_tag', array('id' => 4, 'name' => '--black', 'slug' => 'black', 'test_post' => $post1, 'test_blogs' => array($blog2)));
Jam::create('test_tag', array('id' => 5, 'name' => '* List 1', 'slug' => 'list-1', 'test_post' => $post1, 'test_blogs' => array($blog3)));
Jam::create('test_tag', array('id' => 6, 'name' => '* List 2', 'slug' => 'list-2', 'test_post' => $post1, 'test_blogs' => array($blog3)));
/**
* VIDEOS
*/
Jam::create('test_video', array('id' => 1, 'file' => 'video.jpg', 'test_holder' => $post1, 'position' => 1, 'slug' => 'video-jpg-1', 'group' => 'one'));
Jam::create('test_video', array('id' => 2, 'file' => 'video2.jpg', 'slug' => 'video2-jpg-2', 'position' => 2, 'group' => 'one'));
Jam::create('test_video', array('id' => 3, 'file' => 'video3.jpg', 'test_holder' => $post1, 'deleted' => 1, 'position' => 3, 'slug' => 'video3-jpg-3', 'group' => 'two'));
Jam::create('test_video', array('id' => 4, 'file' => 'video4.jpg', 'test_holder' => $post1, 'position' => 3, 'slug' => 'video4-jpg-4', 'group' => 'two'));
Jam::create('test_video', array('id' => 5, 'file' => 'video5.jpg', 'test_holder' => $post1, 'position' => 3, 'slug' => 'video5-jpg-4', 'group' => 'one'));
/**
* Images
*/
$image1 = Jam::create('test_image', array('id' => 1, 'file' => 'file.jpg', 'test_holder' => $post1));
$image2 = Jam::create('test_image', array('id' => 2, 'file' => 'file2.jpg', 'test_holder' => $author1));
$image3 = Jam::create('test_image', array('id' => 3, 'file' => 'file3.jpg'));
/**
* Copyrights
*/
Jam::create('test_copyright', array('id' => 1, 'name' => 'My Copyright', 'test_image' => $image1));