public function test_moving_and_removing_directories() { $worker = testable_worker::instance(); $root = sys_get_temp_dir().'/'.uniqid('mdeploytest', true); mkdir($root.'/a', 0777, true); touch($root.'/a/a.txt'); $this->assertTrue(file_exists($root.'/a/a.txt')); $this->assertFalse(file_exists($root.'/b/a.txt')); $this->assertTrue($worker->move_directory($root.'/a', $root.'/b')); $this->assertFalse(is_dir($root.'/a')); $this->assertTrue(file_exists($root.'/b/a.txt')); $this->assertTrue($worker->move_directory($root.'/b', $root.'/c', true)); $this->assertTrue(file_exists($root.'/c/a.txt')); $this->assertFalse(file_exists($root.'/b/a.txt')); $this->assertTrue(is_dir($root.'/b')); $this->assertTrue($worker->remove_directory($root.'/c', true)); $this->assertFalse(file_exists($root.'/c/a.txt')); $this->assertTrue($worker->remove_directory($root.'/c')); $this->assertFalse(is_dir($root.'/c')); }
public function test_create_directory_precheck() { $worker = testable_worker::instance(); $root = sys_get_temp_dir() . '/' . uniqid('mdeploytest', true); $this->assertFalse(file_exists($root)); $this->assertTrue($worker->create_directory_precheck($root)); $this->assertFalse(file_exists($root)); // The precheck is supposed to remove it again. }
/** * Test that a valid setting with data returns that data. * * @dataProvider get_env_valid_provider */ public function test_get_env_valid($key) { // Ensure that the setting is currently unset. global $CFG; $CFG->{$key} = rand(0, 1000); $worker = testable_worker::instance(); $value = $worker->get_env($key); $this->assertEquals($CFG->{$key}, $value); }