[ticket/16604] Do not test avatar upload directory permissions on Windows

PHPBB3-16604
This commit is contained in:
rxu 2020-09-22 18:59:04 +07:00
parent f4287e1f56
commit 4698d20fb4
No known key found for this signature in database
GPG key ID: 955F0567380E586A

View file

@ -53,27 +53,31 @@ class phpbb_functional_acp_avatar_settings_test extends phpbb_functional_test_ca
$this->assertContainsLang('AVATAR_NO_UPLOAD_PATH', $crawler->filter('div[class="errorbox"] > p')->text()); $this->assertContainsLang('AVATAR_NO_UPLOAD_PATH', $crawler->filter('div[class="errorbox"] > p')->text());
// Test avatar upload path became not writable on the server afterwards // Test avatar upload path became not writable on the server afterwards
$crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); // Unix tests only
$form = $crawler->selectButton($this->lang('SUBMIT'))->form(); if (!defined('PHP_WINDOWS_VERSION_MAJOR'))
$values = $form->getValues(); {
$avatar_upload_path = $values['config[avatar_path]']; $crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid);
$filesystem = new \phpbb\filesystem\filesystem; $form = $crawler->selectButton($this->lang('SUBMIT'))->form();
// Make the directory not writable $values = $form->getValues();
global $phpbb_root_path; $avatar_upload_path = $values['config[avatar_path]'];
$filesystem->chmod($phpbb_root_path . $avatar_upload_path, 444); $filesystem = new \phpbb\filesystem\filesystem;
$this->assertFalse($filesystem->is_writable($phpbb_root_path . $avatar_upload_path)); // Make the directory not writable
global $phpbb_root_path;
$filesystem->chmod($phpbb_root_path . $avatar_upload_path, 444);
$this->assertFalse($filesystem->is_writable($phpbb_root_path . $avatar_upload_path));
// Visit Avatar ACP settings again - warning should be displayed // Visit Avatar ACP settings again - warning should be displayed
$crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); $crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid);
$this->assertContainsLang('WARNING', $crawler->filter('div[class="errorbox"] > h3')->text()); $this->assertContainsLang('WARNING', $crawler->filter('div[class="errorbox"] > h3')->text());
$this->assertContainsLang('AVATAR_NO_UPLOAD_DIR', $crawler->filter('div[class="errorbox"] > p')->text()); $this->assertContainsLang('AVATAR_NO_UPLOAD_DIR', $crawler->filter('div[class="errorbox"] > p')->text());
// Restore default state // Restore default state
$filesystem->chmod($phpbb_root_path . $avatar_upload_path, 777); $filesystem->chmod($phpbb_root_path . $avatar_upload_path, 777);
$this->assertTrue($filesystem->is_writable($phpbb_root_path . $avatar_upload_path)); $this->assertTrue($filesystem->is_writable($phpbb_root_path . $avatar_upload_path));
$crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); $crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid);
$this->assertNotContainsLang('AVATAR_NO_UPLOAD_DIR', $this->get_content()); $this->assertNotContainsLang('AVATAR_NO_UPLOAD_DIR', $this->get_content());
$this->assertNotContainsLang('AVATAR_NO_UPLOAD_PATH', $this->get_content()); $this->assertNotContainsLang('AVATAR_NO_UPLOAD_PATH', $this->get_content());
}
} }
} }