Some more test work

- When cleaning up, make sure we're the original user.  Some tests & failures leave it logged out
- Some better messages
This commit is contained in:
nathangray 2020-09-23 12:59:57 -06:00
parent dd1a51d5fa
commit ff50af5677
2 changed files with 12 additions and 18 deletions

View File

@ -77,14 +77,15 @@ class SharingBase extends LoggedInTest
protected function tearDown() : void protected function tearDown() : void
{ {
LoggedInTest::tearDownAfterClass(); try
{
// Some tests may leave us logged out, which will cause failures in parent cleanup
LoggedInTest::tearDownAfterClass();
}
catch(\Throwable $e) {}
LoggedInTest::setupBeforeClass(); LoggedInTest::setupBeforeClass();
// Re-init, since they look at user, fstab, etc.
// Also, further tests that access the filesystem fail if we don't
Vfs::clearstatcache();
Vfs::init_static();
Vfs\StreamWrapper::init_static();
// Need to ask about mounts, or other tests fail // Need to ask about mounts, or other tests fail
Vfs::mount(); Vfs::mount();
@ -271,8 +272,6 @@ class SharingBase extends LoggedInTest
Vfs::$is_root = false; Vfs::$is_root = false;
$this->mounts[] = $path; $this->mounts[] = $path;
Vfs::clearstatcache();
Vfs::init_static();
} }
/** /**

View File

@ -89,14 +89,9 @@ abstract class StreamWrapperBase extends LoggedInTest
protected function tearDown() : void protected function tearDown() : void
{ {
LoggedInTest::tearDownAfterClass(); // Make sure we're on the original user. Failures could cause us to be logged in as someone else
LoggedInTest::setupBeforeClass(); $this->switchUser($GLOBALS['EGW_USER'], $GLOBALS['EGW_PASSWORD']);
$this->mount();
// Re-init, since they look at user, fstab, etc.
// Also, further tests that access the filesystem fail if we don't
Vfs::clearstatcache();
Vfs::init_static();
// Need to ask about mounts, or other tests fail // Need to ask about mounts, or other tests fail
Vfs::mount(); Vfs::mount();
@ -259,7 +254,7 @@ abstract class StreamWrapperBase extends LoggedInTest
); );
$this->assertFalse( $this->assertFalse(
file_get_contents(Vfs::PREFIX . $file), file_get_contents(Vfs::PREFIX . $file),
"Problem reading someone else's file with no permission" "Read someone else's file with no permission. " . Vfs::PREFIX . $file
); );
} }
@ -318,7 +313,7 @@ abstract class StreamWrapperBase extends LoggedInTest
$this->assertEquals( $this->assertEquals(
$contents, $contents,
file_get_contents(Vfs::PREFIX . $file), file_get_contents(Vfs::PREFIX . $file),
"Problem reading someone else's file with permission" "Problem reading contents of someone else's file (".Vfs::PREFIX . "$file) with permission"
); );
$this->assertTrue( $this->assertTrue(
Vfs::is_readable($file), Vfs::is_readable($file),