Skip to content

Commit b8fbcc2

Browse files
committed
Fix unit tests after #620
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent 87ed718 commit b8fbcc2

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

tests/Unit/Command/GenerateTest.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ protected function setUp(): void {
6464

6565
public function dataExecute() {
6666
return [
67-
['user', '', '', false, null, false, null, 123, null, 1],
68-
['user', '', '', false, null, false, 'user', 123, null, 1],
69-
['user', str_repeat('a', 256), '', false, null, false, 'user', 123, null, 1],
70-
['user', 'short', '', true, false, false, 'user', 123, '7b', 0],
71-
['user', 'short', str_repeat('a', 4001), false, null, false, 'user', 123, null, 1],
72-
['user', 'short', str_repeat('a', 4000), true, false, true, 'user', 123, '7b', 0],
73-
['user', 'short', 'long', true, true, true, 'user', 123, '7b', 1],
67+
['user', '', '', false, null, false, null, false, 1],
68+
['user', '', '', false, null, false, 'user', false, 1],
69+
['user', str_repeat('a', 256), '', false, null, false, 'user', false, 1],
70+
['user', 'short', '', true, false, false, 'user', true, 0],
71+
['user', 'short', str_repeat('a', 4001), false, null, false, 'user', false, 1],
72+
['user', 'short', str_repeat('a', 4000), true, false, true, 'user', true, 0],
73+
['user', 'short', 'long', true, true, true, 'user', true, 1],
7474
];
7575
}
7676

@@ -83,11 +83,10 @@ public function dataExecute() {
8383
* @param bool $notifyThrows
8484
* @param bool $validLong
8585
* @param string|null $user
86-
* @param int $time
87-
* @param string|null $hexTime
86+
* @param bool $isCreated
8887
* @param int $exitCode
8988
*/
90-
public function testExecute($userId, $short, $long, $createNotification, $notifyThrows, $validLong, $user, $time, $hexTime, $exitCode) {
89+
public function testExecute($userId, $short, $long, $createNotification, $notifyThrows, $validLong, $user, $isCreated, $exitCode) {
9190
if ($user !== null) {
9291
$u = $this->createMock(IUser::class);
9392
$u->expects($createNotification ? $this->once() : $this->never())
@@ -101,9 +100,10 @@ public function testExecute($userId, $short, $long, $createNotification, $notify
101100
->with($userId)
102101
->willReturn($u);
103102

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

108108
if ($createNotification) {
109109
$n = $this->createMock(INotification::class);
@@ -117,10 +117,11 @@ public function testExecute($userId, $short, $long, $createNotification, $notify
117117
->willReturnSelf();
118118
$n->expects($this->once())
119119
->method('setDateTime')
120+
->with($dateTime)
120121
->willReturnSelf();
121122
$n->expects($this->once())
122123
->method('setObject')
123-
->with('admin_notifications', $hexTime)
124+
->with('admin_notifications', dechex($dateTime->getTimestamp()))
124125
->willReturnSelf();
125126
$n->expects($this->once())
126127
->method('setSubject')

tests/Unit/Notifier/NotifierTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testPrepareWrongApp() {
6565
/** @var INotification|\PHPUnit_Framework_MockObject_MockObject $notification */
6666
$notification = $this->createMock(INotification::class);
6767

68-
$notification->expects($this->once())
68+
$notification->expects($this->exactly(2))
6969
->method('getApp')
7070
->willReturn('notifications');
7171
$notification->expects($this->never())

0 commit comments

Comments
 (0)