本文整理匯總了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]);
}