Added more unit tests
This commit is contained in:
parent
5d9513bac0
commit
6399afd799
21 changed files with 750 additions and 35 deletions
|
@ -74,7 +74,7 @@ class AddPostJobTest extends AbstractTest
|
||||||
new AddPostJob(),
|
new AddPostJob(),
|
||||||
[
|
[
|
||||||
JobArgs::ARG_NEW_SAFETY => PostSafety::Safe,
|
JobArgs::ARG_NEW_SAFETY => PostSafety::Safe,
|
||||||
JobArgs::ARG_NEW_SOURCE => '',
|
JobArgs::ARG_NEW_SOURCE => 'this should make it fail',
|
||||||
JobArgs::ARG_NEW_POST_CONTENT => new ApiFileInput($this->getPath('image.jpg'), 'test.jpg'),
|
JobArgs::ARG_NEW_POST_CONTENT => new ApiFileInput($this->getPath('image.jpg'), 'test.jpg'),
|
||||||
]);
|
]);
|
||||||
}, 'Insufficient privilege');
|
}, 'Insufficient privilege');
|
||||||
|
|
|
@ -122,7 +122,7 @@ class AddUserJobTest extends AbstractTest
|
||||||
JobArgs::ARG_NEW_USER_NAME => 'dummy',
|
JobArgs::ARG_NEW_USER_NAME => 'dummy',
|
||||||
JobArgs::ARG_NEW_PASSWORD => 'sekai',
|
JobArgs::ARG_NEW_PASSWORD => 'sekai',
|
||||||
]);
|
]);
|
||||||
}, 'User with');
|
}, 'User with this name is already registered');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAccessRankDenial()
|
public function testAccessRankDenial()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
class DeleteCommentJobTest extends AbstractTest
|
class DeleteCommentJobTest extends AbstractTest
|
||||||
{
|
{
|
||||||
public function testOwn()
|
public function testRemoval()
|
||||||
{
|
{
|
||||||
$this->prepare();
|
$this->prepare();
|
||||||
$this->grantAccess('deleteComment');
|
$this->grantAccess('deleteComment');
|
||||||
|
|
40
tests/JobTests/DeletePostJobTest.php
Normal file
40
tests/JobTests/DeletePostJobTest.php
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
class DeletePostJobTest extends AbstractTest
|
||||||
|
{
|
||||||
|
public function testRemoval()
|
||||||
|
{
|
||||||
|
$user = $this->mockUser();
|
||||||
|
$post = $this->mockPost($user);
|
||||||
|
$this->login($user);
|
||||||
|
$this->grantAccess('deletePost');
|
||||||
|
|
||||||
|
$this->assert->doesNotThrow(function() use ($post)
|
||||||
|
{
|
||||||
|
Api::run(
|
||||||
|
new DeletePostJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_POST_NAME => $post->getName(),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->assert->areEqual(null, PostModel::tryGetByName($post->getName()));
|
||||||
|
$this->assert->areEqual(0, PostModel::getCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWrongPostId()
|
||||||
|
{
|
||||||
|
$user = $this->mockUser();
|
||||||
|
$post = $this->mockPost($user);
|
||||||
|
$this->login($user);
|
||||||
|
|
||||||
|
$this->assert->throws(function()
|
||||||
|
{
|
||||||
|
Api::run(
|
||||||
|
new DeletePostJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_POST_NAME => 'robocop',
|
||||||
|
]);
|
||||||
|
}, 'Invalid post name');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
37
tests/JobTests/DeleteUserJobTest.php
Normal file
37
tests/JobTests/DeleteUserJobTest.php
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
class DeleteUserJobTest extends AbstractTest
|
||||||
|
{
|
||||||
|
public function testRemoval()
|
||||||
|
{
|
||||||
|
$user = $this->mockUser();
|
||||||
|
$this->login($user);
|
||||||
|
$this->grantAccess('deleteUser');
|
||||||
|
|
||||||
|
$this->assert->doesNotThrow(function() use ($user)
|
||||||
|
{
|
||||||
|
Api::run(
|
||||||
|
new DeleteUserJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_USER_NAME => $user->getName(),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->assert->areEqual(null, UserModel::tryGetByName($user->getName()));
|
||||||
|
$this->assert->areEqual(0, UserModel::getCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWrongUserId()
|
||||||
|
{
|
||||||
|
$user = $this->mockUser();
|
||||||
|
$this->login($user);
|
||||||
|
|
||||||
|
$this->assert->throws(function()
|
||||||
|
{
|
||||||
|
Api::run(
|
||||||
|
new DeleteUserJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_USER_NAME => 'robocop',
|
||||||
|
]);
|
||||||
|
}, 'Invalid user name');
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,6 +10,10 @@ class EditPostContentJobTest extends AbstractTest
|
||||||
{
|
{
|
||||||
PostModel::getById($post->getId());
|
PostModel::getById($post->getId());
|
||||||
});
|
});
|
||||||
|
$this->assert->isTrue($post->getFileSize() > 0);
|
||||||
|
$this->assert->isNotNull($post->getFileHash());
|
||||||
|
$this->assert->isNotNull($post->getMimeType());
|
||||||
|
$this->assert->isNotNull($post->getType()->toInteger());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFileJpeg()
|
public function testFileJpeg()
|
||||||
|
@ -76,6 +80,10 @@ class EditPostContentJobTest extends AbstractTest
|
||||||
{
|
{
|
||||||
PostModel::getById($post->getId());
|
PostModel::getById($post->getId());
|
||||||
});
|
});
|
||||||
|
$this->assert->isTrue($post->getFileSize() > 0);
|
||||||
|
$this->assert->isNotNull($post->getFileHash());
|
||||||
|
$this->assert->isNotNull($post->getMimeType());
|
||||||
|
$this->assert->isNotNull($post->getType()->toInteger());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUrlYoutube()
|
public function testUrlYoutube()
|
||||||
|
@ -88,7 +96,7 @@ class EditPostContentJobTest extends AbstractTest
|
||||||
new EditPostContentJob(),
|
new EditPostContentJob(),
|
||||||
[
|
[
|
||||||
JobArgs::ARG_POST_ID => $post->getId(),
|
JobArgs::ARG_POST_ID => $post->getId(),
|
||||||
JobArgs::ARG_NEW_POST_CONTENT_URL => 'http://www.youtube.com/watch?v=qWq_jydCUw4', 'test.jpg',
|
JobArgs::ARG_NEW_POST_CONTENT_URL => 'http://www.youtube.com/watch?v=qWq_jydCUw4',
|
||||||
]);
|
]);
|
||||||
$this->assert->areEqual(PostType::Youtube, $post->getType()->toInteger());
|
$this->assert->areEqual(PostType::Youtube, $post->getType()->toInteger());
|
||||||
$this->assert->areEqual('qWq_jydCUw4', $post->getFileHash());
|
$this->assert->areEqual('qWq_jydCUw4', $post->getFileHash());
|
||||||
|
@ -117,6 +125,57 @@ class EditPostContentJobTest extends AbstractTest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testDuplicateFile()
|
||||||
|
{
|
||||||
|
$this->prepare();
|
||||||
|
$this->grantAccess('editPostContent');
|
||||||
|
$post = $this->uploadFromFile('image.png');
|
||||||
|
$this->assert->areEqual('image/png', $post->getMimeType());
|
||||||
|
$this->assert->throws(function()
|
||||||
|
{
|
||||||
|
$this->uploadFromFile('image.png');
|
||||||
|
}, 'Duplicate upload: @1');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDuplicateUrl()
|
||||||
|
{
|
||||||
|
$this->prepare();
|
||||||
|
$this->grantAccess('editPostContent');
|
||||||
|
$post = $this->uploadFromUrl('image.png');
|
||||||
|
$this->assert->areEqual('image/png', $post->getMimeType());
|
||||||
|
$this->assert->throws(function()
|
||||||
|
{
|
||||||
|
$this->uploadFromUrl('image.png');
|
||||||
|
}, 'Duplicate upload: @1');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDuplicateYoutube()
|
||||||
|
{
|
||||||
|
$this->prepare();
|
||||||
|
$this->grantAccess('editPostContent');
|
||||||
|
|
||||||
|
$url = 'http://www.youtube.com/watch?v=qWq_jydCUw4';
|
||||||
|
|
||||||
|
$post = $this->mockPost(Auth::getCurrentUser());
|
||||||
|
$post = Api::run(
|
||||||
|
new EditPostContentJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_POST_ID => $post->getId(),
|
||||||
|
JobArgs::ARG_NEW_POST_CONTENT_URL => $url,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$post = $this->mockPost(Auth::getCurrentUser());
|
||||||
|
$this->assert->throws(function() use ($post, $url)
|
||||||
|
{
|
||||||
|
Api::run(
|
||||||
|
new EditPostContentJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_POST_ID => $post->getId(),
|
||||||
|
JobArgs::ARG_NEW_POST_CONTENT_URL => $url,
|
||||||
|
]);
|
||||||
|
}, 'Duplicate upload: @1');
|
||||||
|
}
|
||||||
|
|
||||||
protected function prepare()
|
protected function prepare()
|
||||||
{
|
{
|
||||||
$this->login($this->mockUser());
|
$this->login($this->mockUser());
|
||||||
|
|
|
@ -25,7 +25,7 @@ class EditPostJobTest extends AbstractTest
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPrivilegeFail()
|
public function testPartialPrivilegeFail()
|
||||||
{
|
{
|
||||||
$this->grantAccess('editPost');
|
$this->grantAccess('editPost');
|
||||||
$this->grantAccess('editPostSafety');
|
$this->grantAccess('editPostSafety');
|
||||||
|
@ -38,7 +38,7 @@ class EditPostJobTest extends AbstractTest
|
||||||
[
|
[
|
||||||
JobArgs::ARG_POST_ID => $post->getId(),
|
JobArgs::ARG_POST_ID => $post->getId(),
|
||||||
JobArgs::ARG_NEW_SAFETY => PostSafety::Safe,
|
JobArgs::ARG_NEW_SAFETY => PostSafety::Safe,
|
||||||
JobArgs::ARG_NEW_SOURCE => '',
|
JobArgs::ARG_NEW_SOURCE => 'this should make it fail',
|
||||||
JobArgs::ARG_NEW_POST_CONTENT => new ApiFileInput($this->getPath('image.jpg'), 'test.jpg'),
|
JobArgs::ARG_NEW_POST_CONTENT => new ApiFileInput($this->getPath('image.jpg'), 'test.jpg'),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
63
tests/JobTests/EditPostSafetyJobTest.php
Normal file
63
tests/JobTests/EditPostSafetyJobTest.php
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
<?php
|
||||||
|
class EditPostSafetyJobTest extends AbstractTest
|
||||||
|
{
|
||||||
|
public function testSaving()
|
||||||
|
{
|
||||||
|
$this->prepare();
|
||||||
|
$this->grantAccess('editPostSafety.own');
|
||||||
|
|
||||||
|
$post = $this->mockPost(Auth::getCurrentUser());
|
||||||
|
$post = $this->assert->doesNotThrow(function() use ($post)
|
||||||
|
{
|
||||||
|
return Api::run(
|
||||||
|
new EditPostSafetyJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_POST_ID => $post->getId(),
|
||||||
|
JobArgs::ARG_NEW_SAFETY => PostSafety::Sketchy,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->assert->areEqual(PostSafety::Sketchy, $post->getSafety()->toInteger());
|
||||||
|
$this->assert->doesNotThrow(function() use ($post)
|
||||||
|
{
|
||||||
|
PostModel::getById($post->getId());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWrongPostId()
|
||||||
|
{
|
||||||
|
$this->prepare();
|
||||||
|
|
||||||
|
$this->assert->throws(function()
|
||||||
|
{
|
||||||
|
Api::run(
|
||||||
|
new EditPostSafetyJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_POST_ID => 100,
|
||||||
|
JobArgs::ARG_NEW_SAFETY => PostSafety::Sketchy,
|
||||||
|
]);
|
||||||
|
}, 'Invalid post ID');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWrongSafety()
|
||||||
|
{
|
||||||
|
$this->prepare();
|
||||||
|
$this->grantAccess('editPostSafety.own');
|
||||||
|
|
||||||
|
$post = $this->mockPost(Auth::getCurrentUser());
|
||||||
|
$this->assert->throws(function() use ($post)
|
||||||
|
{
|
||||||
|
Api::run(
|
||||||
|
new EditPostSafetyJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_POST_ID => $post->getId(),
|
||||||
|
JobArgs::ARG_NEW_SAFETY => '',
|
||||||
|
]);
|
||||||
|
}, 'Invalid safety type');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function prepare()
|
||||||
|
{
|
||||||
|
$this->login($this->mockUser());
|
||||||
|
}
|
||||||
|
}
|
|
@ -37,6 +37,17 @@ class EditPostSourceJobTest extends AbstractTest
|
||||||
}, 'Source must have at most');
|
}, 'Source must have at most');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testEmptyText()
|
||||||
|
{
|
||||||
|
$this->prepare();
|
||||||
|
$this->grantAccess('editPostSource.own');
|
||||||
|
$post = $this->assert->doesNotThrow(function()
|
||||||
|
{
|
||||||
|
return $this->runApi('');
|
||||||
|
});
|
||||||
|
$this->assert->areEqual('', $post->getSource());
|
||||||
|
}
|
||||||
|
|
||||||
public function testWrongPostId()
|
public function testWrongPostId()
|
||||||
{
|
{
|
||||||
$this->prepare();
|
$this->prepare();
|
||||||
|
|
|
@ -74,6 +74,35 @@ class EditUserEmailJobTest extends AbstractTest
|
||||||
JobArgs::ARG_NEW_EMAIL => 'hrmfbpdvpds@brtedf',
|
JobArgs::ARG_NEW_EMAIL => 'hrmfbpdvpds@brtedf',
|
||||||
]);
|
]);
|
||||||
}, 'E-mail address appears to be invalid');
|
}, 'E-mail address appears to be invalid');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testChangingToExistingDenial()
|
||||||
|
{
|
||||||
|
getConfig()->registration->needEmailForRegistering = false;
|
||||||
|
Mailer::mockSending();
|
||||||
|
$this->assert->areEqual(0, Mailer::getMailCounter());
|
||||||
|
|
||||||
|
getConfig()->privileges->changeUserEmailNoConfirm = 'anonymous';
|
||||||
|
$this->grantAccess('changeUserEmail');
|
||||||
|
|
||||||
|
$user = $this->mockUser();
|
||||||
|
$otherUser = $this->mockUser();
|
||||||
|
$otherUser->setUnconfirmedEmail('super@mario.plumbing');
|
||||||
|
UserModel::save($otherUser);
|
||||||
|
|
||||||
|
$this->assert->throws(function() use ($user, $otherUser)
|
||||||
|
{
|
||||||
|
Api::run(
|
||||||
|
new EditUserEmailJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_USER_NAME => $user->getName(),
|
||||||
|
JobArgs::ARG_NEW_EMAIL => $otherUser->getUnconfirmedEmail(),
|
||||||
|
]);
|
||||||
|
}, 'User with this e-mail is already registered');
|
||||||
|
|
||||||
|
$this->assert->areEqual(null, $user->getUnconfirmedEmail());
|
||||||
|
$this->assert->areEqual(null, $user->getConfirmedEmail());
|
||||||
|
|
||||||
|
$this->assert->areEqual(0, Mailer::getMailCounter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,25 @@ class EditUserJobTest extends AbstractTest
|
||||||
$this->assert->isFalse(empty($user->getPasswordHash()));
|
$this->assert->isFalse(empty($user->getPasswordHash()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPartialPrivilegeFail()
|
||||||
|
{
|
||||||
|
$this->grantAccess('changeUserName.own');
|
||||||
|
$user = $this->mockUser();
|
||||||
|
|
||||||
|
$newName = 'dummy' . uniqid();
|
||||||
|
|
||||||
|
$this->assert->throws(function() use ($user, $newName)
|
||||||
|
{
|
||||||
|
return Api::run(
|
||||||
|
new EditUserJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_USER_NAME => $user->getName(),
|
||||||
|
JobArgs::ARG_NEW_USER_NAME => $newName,
|
||||||
|
JobArgs::ARG_NEW_PASSWORD => 'this should make it fail',
|
||||||
|
]);
|
||||||
|
}, 'Insufficient privilege');
|
||||||
|
}
|
||||||
|
|
||||||
public function testLogBuffering()
|
public function testLogBuffering()
|
||||||
{
|
{
|
||||||
$this->testSaving();
|
$this->testSaving();
|
||||||
|
|
101
tests/JobTests/EditUserNameJobTest.php
Normal file
101
tests/JobTests/EditUserNameJobTest.php
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
<?php
|
||||||
|
class EditUserNameJobTest extends AbstractTest
|
||||||
|
{
|
||||||
|
public function testEditing()
|
||||||
|
{
|
||||||
|
$this->grantAccess('changeUserName');
|
||||||
|
$user = $this->mockUser();
|
||||||
|
|
||||||
|
$newName = uniqid();
|
||||||
|
|
||||||
|
$this->assert->areNotEqual($newName, $user->getName());
|
||||||
|
|
||||||
|
$user = $this->assert->doesNotThrow(function() use ($user, $newName)
|
||||||
|
{
|
||||||
|
return Api::run(
|
||||||
|
new EditUserNameJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_USER_NAME => $user->getName(),
|
||||||
|
JobArgs::ARG_NEW_USER_NAME => $newName,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->assert->areEqual($newName, $user->getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTooShortName()
|
||||||
|
{
|
||||||
|
$this->grantAccess('changeUserName');
|
||||||
|
$user = $this->mockUser();
|
||||||
|
|
||||||
|
$newName = str_repeat('a', getConfig()->registration->userNameMinLength - 1);
|
||||||
|
|
||||||
|
$this->assert->throws(function() use ($user, $newName)
|
||||||
|
{
|
||||||
|
Api::run(
|
||||||
|
new EditUserNameJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_USER_NAME => $user->getName(),
|
||||||
|
JobArgs::ARG_NEW_USER_NAME => $newName,
|
||||||
|
]);
|
||||||
|
}, 'user name must have at least');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTooLongName()
|
||||||
|
{
|
||||||
|
$this->grantAccess('changeUserName');
|
||||||
|
$user = $this->mockUser();
|
||||||
|
|
||||||
|
$newName = str_repeat('a', getConfig()->registration->userNameMaxLength + 1);
|
||||||
|
|
||||||
|
$this->assert->throws(function() use ($user, $newName)
|
||||||
|
{
|
||||||
|
Api::run(
|
||||||
|
new EditUserNameJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_USER_NAME => $user->getName(),
|
||||||
|
JobArgs::ARG_NEW_USER_NAME => $newName,
|
||||||
|
]);
|
||||||
|
}, 'user name must have at most');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testInvalidName()
|
||||||
|
{
|
||||||
|
$this->grantAccess('changeUserName');
|
||||||
|
$user = $this->mockUser();
|
||||||
|
|
||||||
|
$newName = 'ble/ble';
|
||||||
|
|
||||||
|
$this->assert->throws(function() use ($user, $newName)
|
||||||
|
{
|
||||||
|
Api::run(
|
||||||
|
new EditUserNameJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_USER_NAME => $user->getName(),
|
||||||
|
JobArgs::ARG_NEW_USER_NAME => $newName,
|
||||||
|
]);
|
||||||
|
}, 'user name contains invalid characters');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testChangingToExistingDenial()
|
||||||
|
{
|
||||||
|
$this->grantAccess('changeUserName');
|
||||||
|
$user = $this->mockUser();
|
||||||
|
$otherUser = $this->mockUser();
|
||||||
|
|
||||||
|
$newName = $otherUser->getName();
|
||||||
|
$this->assert->areNotEqual($newName, $user->getName());
|
||||||
|
|
||||||
|
$this->assert->throws(function() use ($user, $newName)
|
||||||
|
{
|
||||||
|
Api::run(
|
||||||
|
new EditUserNameJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_USER_NAME => $user->getName(),
|
||||||
|
JobArgs::ARG_NEW_USER_NAME => $newName,
|
||||||
|
]);
|
||||||
|
}, 'User with this name is already registered');
|
||||||
|
|
||||||
|
$this->assert->areNotEqual($newName, $user->getName());
|
||||||
|
}
|
||||||
|
}
|
61
tests/JobTests/EditUserPasswordJobTest.php
Normal file
61
tests/JobTests/EditUserPasswordJobTest.php
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
<?php
|
||||||
|
class EditUserPasswordJobTest extends AbstractTest
|
||||||
|
{
|
||||||
|
public function testEditing()
|
||||||
|
{
|
||||||
|
$this->testValidPassword('flintstone');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testVeryLongPassword()
|
||||||
|
{
|
||||||
|
$this->testValidPassword(str_repeat('flintstone', 100));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTooShortPassword()
|
||||||
|
{
|
||||||
|
$this->grantAccess('changeUserPassword');
|
||||||
|
$user = $this->mockUser();
|
||||||
|
|
||||||
|
$newPassword = str_repeat('a', getConfig()->registration->passMinLength - 1);
|
||||||
|
$oldPasswordHash = $user->getPasswordHash();
|
||||||
|
|
||||||
|
$this->assert->throws(function() use ($user, $newPassword)
|
||||||
|
{
|
||||||
|
return Api::run(
|
||||||
|
new EditUserPasswordJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_USER_NAME => $user->getName(),
|
||||||
|
JobArgs::ARG_NEW_PASSWORD => $newPassword,
|
||||||
|
]);
|
||||||
|
}, 'Password must have at least');
|
||||||
|
|
||||||
|
$this->assert->areEqual($oldPasswordHash, $user->getPasswordHash());
|
||||||
|
}
|
||||||
|
|
||||||
|
private function testValidPassword($newPassword)
|
||||||
|
{
|
||||||
|
$this->grantAccess('changeUserPassword');
|
||||||
|
$user = $this->mockUser();
|
||||||
|
|
||||||
|
$newPasswordHash = UserModel::hashPassword($newPassword, $user->getPasswordSalt());
|
||||||
|
|
||||||
|
$user = $this->assert->doesNotThrow(function() use ($user, $newPassword)
|
||||||
|
{
|
||||||
|
return Api::run(
|
||||||
|
new EditUserPasswordJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_USER_NAME => $user->getName(),
|
||||||
|
JobArgs::ARG_NEW_PASSWORD => $newPassword,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->assert->areEqual($newPasswordHash, $user->getPasswordHash());
|
||||||
|
|
||||||
|
getConfig()->registration->needEmailForRegistering = false;
|
||||||
|
$this->assert->doesNotThrow(function() use ($user, $newPassword)
|
||||||
|
{
|
||||||
|
Auth::login($user->getName(), $newPassword, false);
|
||||||
|
});
|
||||||
|
$this->assert->isTrue(Auth::isLoggedIn());
|
||||||
|
}
|
||||||
|
}
|
48
tests/JobTests/FlagPostJobTest.php
Normal file
48
tests/JobTests/FlagPostJobTest.php
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
class FlagPostJobTest extends AbstractTest
|
||||||
|
{
|
||||||
|
public function testFlagging()
|
||||||
|
{
|
||||||
|
$this->grantAccess('flagPost');
|
||||||
|
$post = $this->mockPost($this->mockUser());
|
||||||
|
|
||||||
|
$post = $this->assert->doesNotThrow(function() use ($post)
|
||||||
|
{
|
||||||
|
return Api::run(
|
||||||
|
new FlagPostJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_POST_NAME => $post->getName(),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
$logPath = Logger::getLogPath();
|
||||||
|
$logs = file_get_contents($logPath);
|
||||||
|
$logs = array_filter(explode("\n", $logs));
|
||||||
|
$this->assert->areEqual(1, count($logs));
|
||||||
|
$this->assert->isTrue(strpos($logs[0], 'flagged @' . $post->getId() . ' for moderator attention') !== false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDoubleFlagging()
|
||||||
|
{
|
||||||
|
$this->grantAccess('flagPost');
|
||||||
|
$post = $this->mockPost($this->mockUser());
|
||||||
|
|
||||||
|
$this->assert->doesNotThrow(function() use ($post)
|
||||||
|
{
|
||||||
|
Api::run(
|
||||||
|
new FlagPostJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_POST_NAME => $post->getName(),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->assert->throws(function() use ($post)
|
||||||
|
{
|
||||||
|
return Api::run(
|
||||||
|
new FlagPostJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_POST_NAME => $post->getName(),
|
||||||
|
]);
|
||||||
|
}, 'You already flagged this post');
|
||||||
|
}
|
||||||
|
}
|
48
tests/JobTests/FlagUserJobTest.php
Normal file
48
tests/JobTests/FlagUserJobTest.php
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
class FlagUserJobTest extends AbstractTest
|
||||||
|
{
|
||||||
|
public function testFlagging()
|
||||||
|
{
|
||||||
|
$this->grantAccess('flagUser');
|
||||||
|
$user = $this->mockUser();
|
||||||
|
|
||||||
|
$user = $this->assert->doesNotThrow(function() use ($user)
|
||||||
|
{
|
||||||
|
return Api::run(
|
||||||
|
new FlagUserJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_USER_NAME => $user->getName(),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
$logPath = Logger::getLogPath();
|
||||||
|
$logs = file_get_contents($logPath);
|
||||||
|
$logs = array_filter(explode("\n", $logs));
|
||||||
|
$this->assert->areEqual(1, count($logs));
|
||||||
|
$this->assert->isTrue(strpos($logs[0], 'flagged +' . $user->getName() . ' for moderator attention') !== false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDoubleFlagging()
|
||||||
|
{
|
||||||
|
$this->grantAccess('flagUser');
|
||||||
|
$user = $this->mockUser();
|
||||||
|
|
||||||
|
$this->assert->doesNotThrow(function() use ($user)
|
||||||
|
{
|
||||||
|
Api::run(
|
||||||
|
new FlagUserJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_USER_NAME => $user->getName(),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->assert->throws(function() use ($user)
|
||||||
|
{
|
||||||
|
return Api::run(
|
||||||
|
new FlagUserJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_USER_NAME => $user->getName(),
|
||||||
|
]);
|
||||||
|
}, 'You already flagged this user');
|
||||||
|
}
|
||||||
|
}
|
141
tests/JobTests/TogglePostTagJobTest.php
Normal file
141
tests/JobTests/TogglePostTagJobTest.php
Normal file
|
@ -0,0 +1,141 @@
|
||||||
|
<?php
|
||||||
|
class TogglePostTagJobTest extends AbstractTest
|
||||||
|
{
|
||||||
|
public function testEnabling()
|
||||||
|
{
|
||||||
|
$post = $this->preparePost(['test']);
|
||||||
|
|
||||||
|
$this->assertHasTag($post, 'test');
|
||||||
|
$this->assertDoesNotHaveTag($post, 'test2');
|
||||||
|
|
||||||
|
$post = $this->assert->doesNotThrow(function() use ($post)
|
||||||
|
{
|
||||||
|
return $this->addTag($post, 'test2');
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->assertHasTag($post, 'test');
|
||||||
|
$this->assertHasTag($post, 'test2');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testEnablingAlreadyEnabled()
|
||||||
|
{
|
||||||
|
$post = $this->preparePost(['test']);
|
||||||
|
|
||||||
|
$this->assertHasTag($post, 'test');
|
||||||
|
$this->assertDoesNotHaveTag($post, 'test2');
|
||||||
|
|
||||||
|
$post = $this->assert->doesNotThrow(function() use ($post)
|
||||||
|
{
|
||||||
|
return $this->addTag($post, 'test2');
|
||||||
|
});
|
||||||
|
$post = $this->assert->doesNotThrow(function() use ($post)
|
||||||
|
{
|
||||||
|
return $this->addTag($post, 'test2');
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->assertHasTag($post, 'test');
|
||||||
|
$this->assertHasTag($post, 'test2');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDisabling()
|
||||||
|
{
|
||||||
|
$post = $this->preparePost(['test', 'test2']);
|
||||||
|
|
||||||
|
$this->assertHasTag($post, 'test');
|
||||||
|
$this->assertHasTag($post, 'test2');
|
||||||
|
|
||||||
|
$post = $this->assert->doesNotThrow(function() use ($post)
|
||||||
|
{
|
||||||
|
return $this->removeTag($post, 'test2');
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->assertHasTag($post, 'test');
|
||||||
|
$this->assertDoesNotHaveTag($post, 'test2');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDisablingAlreadyDisabled()
|
||||||
|
{
|
||||||
|
$post = $this->preparePost(['test', 'test2']);
|
||||||
|
|
||||||
|
$this->assertHasTag($post, 'test');
|
||||||
|
$this->assertHasTag($post, 'test2');
|
||||||
|
|
||||||
|
$post = $this->assert->doesNotThrow(function() use ($post)
|
||||||
|
{
|
||||||
|
return $this->removeTag($post, 'test2');
|
||||||
|
});
|
||||||
|
$post = $this->assert->doesNotThrow(function() use ($post)
|
||||||
|
{
|
||||||
|
return $this->removeTag($post, 'test2');
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->assertHasTag($post, 'test');
|
||||||
|
$this->assertDoesNotHaveTag($post, 'test2');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDisablingLastTag()
|
||||||
|
{
|
||||||
|
$post = $this->preparePost(['test']);
|
||||||
|
|
||||||
|
$this->assertHasTag($post, 'test');
|
||||||
|
|
||||||
|
$this->assert->throws(function() use ($post)
|
||||||
|
{
|
||||||
|
$this->removeTag($post, 'test');
|
||||||
|
}, 'No tags set');
|
||||||
|
|
||||||
|
$this->assertHasTag($post, 'test');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function addTag($post, $tagName)
|
||||||
|
{
|
||||||
|
return Api::run(
|
||||||
|
new TogglePostTagJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_POST_ID => $post->getId(),
|
||||||
|
JobArgs::ARG_TAG_NAME => $tagName,
|
||||||
|
JobArgs::ARG_NEW_STATE => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function removeTag($post, $tagName)
|
||||||
|
{
|
||||||
|
return Api::run(
|
||||||
|
new TogglePostTagJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_POST_ID => $post->getId(),
|
||||||
|
JobArgs::ARG_TAG_NAME => $tagName,
|
||||||
|
JobArgs::ARG_NEW_STATE => false,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function assertDoesNotHaveTag($post, $tagName)
|
||||||
|
{
|
||||||
|
$tagNames = $this->getTagNames($post);
|
||||||
|
$this->assert->isFalse(in_array($tagName, $tagNames));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function assertHasTag($post, $tagName)
|
||||||
|
{
|
||||||
|
$tagNames = $this->getTagNames($post);
|
||||||
|
$this->assert->isTrue(in_array($tagName, $tagNames));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function preparePost(array $tagNames)
|
||||||
|
{
|
||||||
|
$this->grantAccess('editPostTags');
|
||||||
|
$post = $this->mockPost($this->mockUser());
|
||||||
|
$post->setTags(TagModel::spawnFromNames($tagNames));
|
||||||
|
PostModel::save($post);
|
||||||
|
return $post;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getTagNames($post)
|
||||||
|
{
|
||||||
|
return array_map(
|
||||||
|
function($tag)
|
||||||
|
{
|
||||||
|
return $tag->getName();
|
||||||
|
}, $post->getTags());
|
||||||
|
}
|
||||||
|
}
|
57
tests/JobTests/ToggleUserBanJobTest.php
Normal file
57
tests/JobTests/ToggleUserBanJobTest.php
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
<?php
|
||||||
|
class ToggleUserBanJobTest extends AbstractTest
|
||||||
|
{
|
||||||
|
public function testBanning()
|
||||||
|
{
|
||||||
|
$this->grantAccess('banUser');
|
||||||
|
$user = $this->mockUser();
|
||||||
|
$this->login($user);
|
||||||
|
|
||||||
|
$this->assert->isFalse($user->isBanned());
|
||||||
|
|
||||||
|
$user = $this->assert->doesNotThrow(function() use ($user)
|
||||||
|
{
|
||||||
|
return Api::run(
|
||||||
|
new ToggleUserBanJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_USER_NAME => $user->getName(),
|
||||||
|
JobArgs::ARG_NEW_STATE => 1,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->assert->isTrue($user->isBanned());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testUnbanning()
|
||||||
|
{
|
||||||
|
$this->grantAccess('banUser');
|
||||||
|
$user = $this->mockUser();
|
||||||
|
$this->login($user);
|
||||||
|
|
||||||
|
$this->assert->isFalse($user->isBanned());
|
||||||
|
|
||||||
|
$user = $this->assert->doesNotThrow(function() use ($user)
|
||||||
|
{
|
||||||
|
return Api::run(
|
||||||
|
new ToggleUserBanJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_USER_NAME => $user->getName(),
|
||||||
|
JobArgs::ARG_NEW_STATE => 1,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->assert->isTrue($user->isBanned());
|
||||||
|
|
||||||
|
$user = $this->assert->doesNotThrow(function() use ($user)
|
||||||
|
{
|
||||||
|
return Api::run(
|
||||||
|
new ToggleUserBanJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_USER_NAME => $user->getName(),
|
||||||
|
JobArgs::ARG_NEW_STATE => 0,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->assert->isFalse($user->isBanned());
|
||||||
|
}
|
||||||
|
}
|
|
@ -48,77 +48,77 @@ class AccessTest extends AbstractTest
|
||||||
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts), $user));
|
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts), $user));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSubPrivileges1()
|
public function testSubPrivilegesOnlySub()
|
||||||
{
|
{
|
||||||
getConfig()->privileges->{'listPosts.dummy'} = 'power-user';
|
getConfig()->privileges->{'listPosts.own'} = 'power-user';
|
||||||
Access::init();
|
Access::init();
|
||||||
|
|
||||||
$user = $this->mockUser();
|
$user = $this->mockUser();
|
||||||
$user->setAccessRank(new AccessRank(AccessRank::PowerUser));
|
$user->setAccessRank(new AccessRank(AccessRank::PowerUser));
|
||||||
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts, 'dummy'), $user));
|
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts, 'own'), $user));
|
||||||
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts, 'baka'), $user));
|
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts, 'all'), $user));
|
||||||
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts), $user));
|
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts), $user));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSubPrivileges2a()
|
public function testSubPrivilegesSubAndGeneralNormalOrder()
|
||||||
{
|
{
|
||||||
getConfig()->privileges->{'listPosts.dummy'} = 'power-user';
|
getConfig()->privileges->{'listPosts.own'} = 'power-user';
|
||||||
getConfig()->privileges->{'listPosts'} = 'admin';
|
getConfig()->privileges->{'listPosts'} = 'admin';
|
||||||
Access::init();
|
Access::init();
|
||||||
$this->testSubPrivileges2();
|
$this->testSubPrivilegesSubAndGeneral();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSubPrivileges2b()
|
public function testSubPrivilegesSubAndGeneralReverseOrder()
|
||||||
{
|
{
|
||||||
getConfig()->privileges->{'listPosts'} = 'admin';
|
getConfig()->privileges->{'listPosts'} = 'admin';
|
||||||
getConfig()->privileges->{'listPosts.dummy'} = 'power-user';
|
getConfig()->privileges->{'listPosts.own'} = 'power-user';
|
||||||
Access::init();
|
Access::init();
|
||||||
$this->testSubPrivileges2();
|
$this->testSubPrivilegesSubAndGeneral();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function testSubPrivileges2()
|
protected function testSubPrivilegesSubAndGeneral()
|
||||||
{
|
{
|
||||||
$user = $this->mockUser();
|
$user = $this->mockUser();
|
||||||
$user->setAccessRank(new AccessRank(AccessRank::PowerUser));
|
$user->setAccessRank(new AccessRank(AccessRank::PowerUser));
|
||||||
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts, 'dummy'), $user));
|
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts, 'own'), $user));
|
||||||
$this->assert->isFalse(Access::check(new Privilege(Privilege::ListPosts, 'baka'), $user));
|
$this->assert->isFalse(Access::check(new Privilege(Privilege::ListPosts, 'baka'), $user));
|
||||||
$this->assert->isFalse(Access::check(new Privilege(Privilege::ListPosts), $user));
|
$this->assert->isFalse(Access::check(new Privilege(Privilege::ListPosts), $user));
|
||||||
|
|
||||||
$user->setAccessRank(new AccessRank(AccessRank::Admin));
|
$user->setAccessRank(new AccessRank(AccessRank::Admin));
|
||||||
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts, 'dummy'), $user));
|
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts, 'own'), $user));
|
||||||
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts, 'baka'), $user));
|
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts, 'all'), $user));
|
||||||
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts), $user));
|
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts), $user));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSubPrivileges3a()
|
public function testSubPrivilegesMultipleSubAndGeneralNormalOrder()
|
||||||
{
|
{
|
||||||
getConfig()->privileges->{'listPosts.dummy'} = 'power-user';
|
getConfig()->privileges->{'listPosts.own'} = 'power-user';
|
||||||
getConfig()->privileges->{'listPosts.baka'} = 'admin';
|
getConfig()->privileges->{'listPosts.all'} = 'admin';
|
||||||
getConfig()->privileges->{'listPosts'} = 'nobody';
|
getConfig()->privileges->{'listPosts'} = 'nobody';
|
||||||
Access::init();
|
Access::init();
|
||||||
$this->testSubPrivileges3();
|
$this->testSubPrivilegesMultipleSubAndGeneral();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSubPrivileges3b()
|
public function testSubPrivilegesMultipleSubAndGeneralReverseOrder()
|
||||||
{
|
{
|
||||||
getConfig()->privileges->{'listPosts'} = 'nobody';
|
getConfig()->privileges->{'listPosts'} = 'nobody';
|
||||||
getConfig()->privileges->{'listPosts.dummy'} = 'power-user';
|
getConfig()->privileges->{'listPosts.own'} = 'power-user';
|
||||||
getConfig()->privileges->{'listPosts.baka'} = 'admin';
|
getConfig()->privileges->{'listPosts.all'} = 'admin';
|
||||||
Access::init();
|
Access::init();
|
||||||
$this->testSubPrivileges3();
|
$this->testSubPrivilegesMultipleSubAndGeneral();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function testSubPrivileges3()
|
protected function testSubPrivilegesMultipleSubAndGeneral()
|
||||||
{
|
{
|
||||||
$user = $this->mockUser();
|
$user = $this->mockUser();
|
||||||
$user->setAccessRank(new AccessRank(AccessRank::PowerUser));
|
$user->setAccessRank(new AccessRank(AccessRank::PowerUser));
|
||||||
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts, 'dummy'), $user));
|
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts, 'own'), $user));
|
||||||
$this->assert->isFalse(Access::check(new Privilege(Privilege::ListPosts, 'baka'), $user));
|
$this->assert->isFalse(Access::check(new Privilege(Privilege::ListPosts, 'all'), $user));
|
||||||
$this->assert->isFalse(Access::check(new Privilege(Privilege::ListPosts), $user));
|
$this->assert->isFalse(Access::check(new Privilege(Privilege::ListPosts), $user));
|
||||||
|
|
||||||
$user->setAccessRank(new AccessRank(AccessRank::Admin));
|
$user->setAccessRank(new AccessRank(AccessRank::Admin));
|
||||||
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts, 'dummy'), $user));
|
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts, 'own'), $user));
|
||||||
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts, 'baka'), $user));
|
$this->assert->isTrue(Access::check(new Privilege(Privilege::ListPosts, 'all'), $user));
|
||||||
$this->assert->isFalse(Access::check(new Privilege(Privilege::ListPosts), $user));
|
$this->assert->isFalse(Access::check(new Privilege(Privilege::ListPosts), $user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,8 @@ class LoggerTest extends AbstractTest
|
||||||
|
|
||||||
public function testPathChanging()
|
public function testPathChanging()
|
||||||
{
|
{
|
||||||
$logPath = __DIR__ . '/logs/{yyyy}-{mm}-{dd}.log';
|
$logPath = dirname(__DIR__) . '/logs/{yyyy}-{mm}-{dd}.log';
|
||||||
$realLogPath = __DIR__ . '/logs/' . date('Y-m-d') . '.log';
|
$realLogPath = dirname(__DIR__) . '/logs/' . date('Y-m-d') . '.log';
|
||||||
|
|
||||||
getConfig()->main->logsPath = $logPath;
|
getConfig()->main->logsPath = $logPath;
|
||||||
$this->assert->doesNotThrow(function()
|
$this->assert->doesNotThrow(function()
|
||||||
|
|
BIN
tests/TestFiles/thumb.jpg
Normal file
BIN
tests/TestFiles/thumb.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 437 B |
|
@ -48,6 +48,7 @@ class TestRunner
|
||||||
|
|
||||||
protected function resetEnvironment()
|
protected function resetEnvironment()
|
||||||
{
|
{
|
||||||
|
$_SESSION = [];
|
||||||
prepareConfig(true);
|
prepareConfig(true);
|
||||||
getConfig()->main->dbDriver = 'sqlite';
|
getConfig()->main->dbDriver = 'sqlite';
|
||||||
getConfig()->main->dbLocation = $this->dbPath;
|
getConfig()->main->dbLocation = $this->dbPath;
|
||||||
|
|
Loading…
Reference in a new issue