/** * Load the environment file, while ensuring read permissions or die trying! * * @return File */ protected function get_env_for_write_or_fail() { try { return File::writable($this->resolve_file_path())->load(); } catch (\Exception $e) { WP_CLI::error($e->getMessage()); } }
/** * @test * @expectedException \WP_CLI_Dotenv\Dotenv\Exception\FilePermissionsException */ public function it_throws_an_exception_if_the_file_is_not_writable() { $path = $this->get_fixture_path('env-unwritable'); chmod($path, 0444); File::writable($path); }