本文整理汇总了PHP中UserStatus::create方法的典型用法代码示例。如果您正苦于以下问题:PHP UserStatus::create方法的具体用法?PHP UserStatus::create怎么用?PHP UserStatus::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserStatus
的用法示例。
在下文中一共展示了UserStatus::create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBelongTo
public function testBelongTo()
{
$this->createPostsWithComments(5, 10);
$this->assertEqual(BlogPost::count(), 5);
$this->assertEqual(BlogComment::count(), 50);
$comment = BlogComment::findFirst(['conditions' => 'title = ?', 'values' => ['Comment 4 to Post 3']]);
$this->assertEqual($comment->message, 'This is a comment message 3:4!');
// Test belongsTo collection
$queryCount = TipyDAO::$queryCount;
$post = $comment->post;
// We got a new query
$this->assertEqual(TipyDAO::$queryCount, $queryCount + 1);
$this->assertNotEqual($post, null);
$this->assertEqual($post->title, 'Post 3');
// Test cached association
$this->assertNotEqual($comment->associationsCache["post"], null);
$this->assertEqual($post, $comment->associationsCache["post"]);
// Test no query
$queryCount = TipyDAO::$queryCount;
$postAgain = $comment->post;
// no more queries
$this->assertEqual(TipyDAO::$queryCount, $queryCount);
$this->assertEqual($post, $postAgain);
// belongsTo crash
$status = UserStatus::create(['name' => 'Some status']);
$user = User::create(['login' => 'login', 'password' => 'password', 'email' => 'email@example.com', 'userStatusId' => $status->id]);
$this->assertEqual($user->userStatus->name, 'Some status');
}