本文整理汇总了PHP中Task::getCategories方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::getCategories方法的具体用法?PHP Task::getCategories怎么用?PHP Task::getCategories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Task
的用法示例。
在下文中一共展示了Task::getCategories方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetCategories
function testGetCategories()
{
$name = "Work stuff";
$id = 1;
$test_category = new Category($name, $id);
$test_category->save();
$name2 = "Volunteer stuff";
$id2 = 2;
$test_category2 = new Category($name2, $id2);
$test_category2->save();
$description = "File reports";
$id3 = 3;
$due_date = "2000-01-01";
$test_task = new Task($description, $id3, $due_date);
$test_task->save();
$test_task->addCategory($test_category);
$test_task->addCategory($test_category2);
$this->assertEquals($test_task->getCategories(), [$test_category, $test_category2]);
}
示例2: testGetCategories
function testGetCategories()
{
//Arrange
$name = "Work stuff";
$id = 1;
$test_category = new Category($name, $id);
$test_category->save();
$name2 = "Volunteer stuff";
$id2 = 2;
$test_category2 = new Category($name2, $id2);
$test_category2->save();
$description = "File reports";
$id3 = 3;
$due_date = null;
$completed = 0;
$test_task = new Task($description, $id3, $completed, $due_date);
$test_task->save();
//Act
$test_task->addCategory($test_category);
$test_task->addCategory($test_category2);
//Assert
$this->assertEquals($test_task->getCategories(), [$test_category, $test_category2]);
}
示例3: Category
function test_getCategories()
{
//Arrange
$name = "Halloween Stuff";
$id = 1;
$test_category = new Category($name, $id);
$test_category->save();
$name2 = "Carve the pumpkin";
$id2 = 2;
$test_category2 = new Category($name2, $id2);
$test_category2->save();
$description = "Scare trick or treaters";
$id3 = 3;
$test_task = new Task($description, $id3);
$test_task->save();
//Act
$test_task->addCategory($test_category);
$test_task->addCategory($test_category2);
//Assert
$this->assertEquals($test_task->getCategories(), [$test_category, $test_category2]);
}
示例4: testGetCategories
function testGetCategories()
{
//Arrange
$name = "Home stuff";
$id = 1;
$test_category = new Category($name, $id);
$test_category->save();
$name2 = "not home stuff";
$id2 = 2;
$test_category2 = new Category($name, $id2);
$test_category2->save();
$description = "File reports";
$id3 = 3;
$test_task = new Task($description, $id3);
$test_task->save();
//Act
$test_task->addCategory($test_category);
$test_task->addCategory($test_category2);
//Assert
$this->assertEquals($test_task->getCategories(), [$test_category, $test_category2]);
}