/** * Tests for basic use with simple numeric progress. */ public function test_basic() { $progress = new core_backup_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(); $progress->progress(2); $this->assertTrue($progress->was_update_called()); $this->assertEquals(120, ini_get('max_execution_time')); // 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.2, 0.2, $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()); // Clear the time limit, otherwise phpunit complains. set_time_limit(0); }
/** * Tests for basic use with simple numeric progress. */ public function test_basic() { $progress = new core_backup_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_backup_progress::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.2, 0.2, $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()); }