本文整理汇总了PHP中Unit::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Unit::getAll方法的具体用法?PHP Unit::getAll怎么用?PHP Unit::getAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit::getAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createFromTimePeriod
/**
* Create weight object from timePeriod widget value
* @param mixed
* @return Weight|null
*/
public static function createFromTimePeriod($arrData)
{
$arrData = deserialize($arrData);
if (empty($arrData) || !is_array($arrData) || $arrData['value'] === '' || $arrData['unit'] === '' || !in_array($arrData['unit'], Unit::getAll())) {
return null;
}
return new static($arrData['value'], $arrData['unit']);
}
示例2: find
static function find($search_id)
{
$found_unit = NULL;
$units = Unit::getAll();
foreach ($units as $unit) {
$unit_id = $unit->getId();
if ($unit_id == $search_id) {
$found_unit = $unit;
}
}
return $found_unit;
}
示例3: testUpdateUnit
function testUpdateUnit()
{
$name = "John Doe";
$password = "password";
$email = "johndoe@osa.biz";
$signed_in = 0;
$test_user = new User($name, $password, $email, $signed_in);
$test_user->save();
$course_title = "Literature";
$subject = "English";
$course_description = "Deconstructing English literature.";
$user_id = $test_user->getId();
$test_course = new Course($course_title, $subject, $course_description, $user_id);
$test_course->save();
$unit_title = "Into the Wild";
$unit_description = "The life and death of Chris McCandless.";
$course_id = $test_course->getId();
$test_unit = new Unit($unit_title, $unit_description, $course_id);
$test_unit->save();
$unit_title2 = "The Catcher in the Rye";
$unit_description2 = "Foul-mouthed kid is angsty.";
$test_unit->updateUnit($unit_title2, $unit_description2);
$result = Unit::getAll();
$this->assertEquals($test_unit, $result[0]);
}