Skip to content

Commit

Permalink
Fix unit tests after #620
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Apr 23, 2020
1 parent 87ed718 commit b8fbcc2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
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

0 comments on commit b8fbcc2

Please sign in to comment.