本文整理汇总了PHP中core_php_time_limit::get_and_clear_unit_test_data方法的典型用法代码示例。如果您正苦于以下问题:PHP core_php_time_limit::get_and_clear_unit_test_data方法的具体用法?PHP core_php_time_limit::get_and_clear_unit_test_data怎么用?PHP core_php_time_limit::get_and_clear_unit_test_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_php_time_limit
的用法示例。
在下文中一共展示了core_php_time_limit::get_and_clear_unit_test_data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_basic
/**
* Tests for basic use with simple numeric progress.
*/
public function test_basic()
{
$progress = new core_mock_progress();
// Check values of empty progress things.
$this->assertFalse($progress->is_in_progress_section());
// Start progress counting, check basic values and check that update
// gets called.
$progress->start_progress('hello', 10);
$this->assertTrue($progress->was_update_called());
$this->assertTrue($progress->is_in_progress_section());
$this->assertEquals('hello', $progress->get_current_description());
// Check numeric position and indeterminate count.
$this->assert_min_max(0.0, 0.0, $progress);
$this->assertEquals(0, $progress->get_progress_count());
// Make some progress and check that the time limit gets added.
$progress->step_time();
core_php_time_limit::get_and_clear_unit_test_data();
$progress->progress(2);
$this->assertTrue($progress->was_update_called());
$this->assertEquals(array(\core\progress\base::TIME_LIMIT_WITHOUT_PROGRESS), core_php_time_limit::get_and_clear_unit_test_data());
// Check the new value.
$this->assert_min_max(0.2, 0.2, $progress);
// Do another progress run at same time, it should be ignored.
$progress->progress(3);
$this->assertFalse($progress->was_update_called());
$this->assert_min_max(0.3, 0.3, $progress);
// End the section. This should cause an update.
$progress->end_progress();
$this->assertTrue($progress->was_update_called());
// Because there are no sections left open, it thinks we finished.
$this->assert_min_max(1.0, 1.0, $progress);
// There was 1 progress call.
$this->assertEquals(1, $progress->get_progress_count());
}