/** * Tests the use of 'R' syntax in time fields of tasks to get * tasks be configured with a non-uniform time. */ public function test_random_time_specification() { // Testing non-deterministic things in a unit test is not really // wise, so we just test the values have changed within allowed bounds. $testclass = new \core\task\scheduled_test_task(); // The test task defaults to '*'. $this->assertInternalType('string', $testclass->get_minute()); $this->assertInternalType('string', $testclass->get_hour()); // Set a random value. $testclass->set_minute('R'); $testclass->set_hour('R'); $testclass->set_day_of_week('R'); // Verify the minute has changed within allowed bounds. $minute = $testclass->get_minute(); $this->assertInternalType('int', $minute); $this->assertGreaterThanOrEqual(0, $minute); $this->assertLessThanOrEqual(59, $minute); // Verify the hour has changed within allowed bounds. $hour = $testclass->get_hour(); $this->assertInternalType('int', $hour); $this->assertGreaterThanOrEqual(0, $hour); $this->assertLessThanOrEqual(23, $hour); // Verify the dayofweek has changed within allowed bounds. $dayofweek = $testclass->get_day_of_week(); $this->assertInternalType('int', $dayofweek); $this->assertGreaterThanOrEqual(0, $dayofweek); $this->assertLessThanOrEqual(6, $dayofweek); }