Skip to content

Commit 3d854b1

Browse files
committed
cliTest for userLastSeen
1 parent 8a147b1 commit 3d854b1

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

Diff for: tests/acceptance/features/bootstrap/OccContext.php

+44
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,19 @@ public function theAdministratorGetsTheGroupsOfUserInJsonUsingTheOccCommand($use
243243
);
244244
}
245245

246+
/**
247+
* @When the administrator retrieves the time when user :username was last seen using the occ command
248+
*
249+
* @param string $username
250+
*
251+
* @return void
252+
*/
253+
public function theAdministratorRetrievesTheTimeWhenUserWasLastSeenUsingTheOccCommand($username) {
254+
$this->featureContext->invokingTheCommand(
255+
"user:lastseen $username"
256+
);
257+
}
258+
246259
/**
247260
* @When the administrator sends a group creation request for group :group using the occ command
248261
*
@@ -500,6 +513,37 @@ public function theDisplayNameReturnedByTheOccCommandShouldBe($displayName) {
500513
PHPUnit_Framework_Assert::assertEquals($displayName, $lastOutputDisplayName);
501514
}
502515

516+
/**
517+
* @Then the command output of user last seen should be recently
518+
*
519+
* @return void
520+
* @throws \Exception
521+
*/
522+
public function theCommandOutputOfUserLastSeenShouldBeRecently() {
523+
$currentTime = \gmdate('d.m.Y H:i');
524+
$currentTimeStamp = \strtotime($currentTime);
525+
$lastOutput = $this->featureContext->getStdOutOfOccCommand();
526+
\preg_match("/([\d.]+ [\d:]+)/", $lastOutput, $userCreatedTime);
527+
$useCreatedTimeStamp = \strtotime(($userCreatedTime[0]));
528+
$delta = $currentTimeStamp - $useCreatedTimeStamp;
529+
if ($delta > 60) {
530+
throw new Exception(__METHOD__ . "User was expected to be seen recently but wasn't");
531+
}
532+
}
533+
534+
/**
535+
* @Then the command output of user last seen should be never
536+
*
537+
* @return void
538+
*/
539+
public function theCommandOutputOfUserLastSeenShouldBeNever() {
540+
$lastOutput = $this->featureContext->getStdOutOfOccCommand();
541+
PHPUnit_Framework_Assert::assertContains(
542+
"has never logged in, yet.",
543+
$lastOutput
544+
);
545+
}
546+
503547
/**
504548
* @When the administrator sets the log level to :level using the occ command
505549
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@cli @skipOnLDAP
2+
Feature: get user last seen
3+
As an admin
4+
I want to be able get user last seen
5+
So that I can see when the user has last logged in the owncloud server
6+
7+
Scenario: admin gets last seen of a user
8+
Given user "brand-new-user" has been created
9+
When the administrator retrieves the time when user "brand-new-user" was last seen using the occ command
10+
Then the command should have been successful
11+
And the command output of user last seen should be recently
12+
13+
Scenario: admin gets last seen of a user who has not been initialized
14+
Given these users have been created but not initialized:
15+
| username |
16+
| brand-new-user |
17+
When the administrator retrieves the time when user "brand-new-user" was last seen using the occ command
18+
Then the command should have been successful
19+
And the command output of user last seen should be never

0 commit comments

Comments
 (0)