Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unit tests after #620 #624

Merged
merged 1 commit into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions tests/Unit/Command/GenerateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ protected function setUp(): void {

public function dataExecute() {
return [
['user', '', '', false, null, false, null, 123, null, 1],
['user', '', '', false, null, false, 'user', 123, null, 1],
['user', str_repeat('a', 256), '', false, null, false, 'user', 123, null, 1],
['user', 'short', '', true, false, false, 'user', 123, '7b', 0],
['user', 'short', str_repeat('a', 4001), false, null, false, 'user', 123, null, 1],
['user', 'short', str_repeat('a', 4000), true, false, true, 'user', 123, '7b', 0],
['user', 'short', 'long', true, true, true, 'user', 123, '7b', 1],
['user', '', '', false, null, false, null, false, 1],
['user', '', '', false, null, false, 'user', false, 1],
['user', str_repeat('a', 256), '', false, null, false, 'user', false, 1],
['user', 'short', '', true, false, false, 'user', true, 0],
['user', 'short', str_repeat('a', 4001), false, null, false, 'user', false, 1],
['user', 'short', str_repeat('a', 4000), true, false, true, 'user', true, 0],
['user', 'short', 'long', true, true, true, 'user', true, 1],
];
}

Expand All @@ -83,11 +83,10 @@ public function dataExecute() {
* @param bool $notifyThrows
* @param bool $validLong
* @param string|null $user
* @param int $time
* @param string|null $hexTime
* @param bool $isCreated
* @param int $exitCode
*/
public function testExecute($userId, $short, $long, $createNotification, $notifyThrows, $validLong, $user, $time, $hexTime, $exitCode) {
public function testExecute($userId, $short, $long, $createNotification, $notifyThrows, $validLong, $user, $isCreated, $exitCode) {
if ($user !== null) {
$u = $this->createMock(IUser::class);
$u->expects($createNotification ? $this->once() : $this->never())
Expand All @@ -101,9 +100,10 @@ public function testExecute($userId, $short, $long, $createNotification, $notify
->with($userId)
->willReturn($u);

$this->timeFactory->expects($hexTime === null ? $this->never() : $this->once())
->method('getTime')
->willReturn($time);
$dateTime = new \DateTime();
$this->timeFactory->expects(!$isCreated ? $this->never() : $this->once())
->method('getDateTime')
->willReturn($dateTime);

if ($createNotification) {
$n = $this->createMock(INotification::class);
Expand All @@ -117,10 +117,11 @@ public function testExecute($userId, $short, $long, $createNotification, $notify
->willReturnSelf();
$n->expects($this->once())
->method('setDateTime')
->with($dateTime)
->willReturnSelf();
$n->expects($this->once())
->method('setObject')
->with('admin_notifications', $hexTime)
->with('admin_notifications', dechex($dateTime->getTimestamp()))
->willReturnSelf();
$n->expects($this->once())
->method('setSubject')
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Notifier/NotifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function testPrepareWrongApp() {
/** @var INotification|\PHPUnit_Framework_MockObject_MockObject $notification */
$notification = $this->createMock(INotification::class);

$notification->expects($this->once())
$notification->expects($this->exactly(2))
->method('getApp')
->willReturn('notifications');
$notification->expects($this->never())
Expand Down