Skip to content

Commit 98d9411

Browse files
committed
Add tests for getUser
1 parent 438615a commit 98d9411

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

tests/acceptance/features/bootstrap/CommandLine.php

+10
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,16 @@ public function theCommandErrorOutputContainsTheText($text) {
467467
);
468468
}
469469

470+
/**
471+
* @Then the occ command JSON output should be empty
472+
*
473+
* @return void
474+
*/
475+
public function theOccCommandJsonOutputShouldNotReturnAnyData() {
476+
PHPUnit_Framework_Assert::assertEquals(\trim($this->lastStdOut), "[]");
477+
PHPUnit_Framework_Assert::assertEmpty($this->lastStdErr);
478+
}
479+
470480
private $lastTransferPath;
471481

472482
/**

tests/acceptance/features/bootstrap/OccContext.php

+27
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,19 @@ public function theAdministratorSendsAUserDeletionRequestForUserUsingTheOccComma
201201
);
202202
}
203203

204+
/**
205+
* @When the administrator retrieves the information of user :username using the occ command
206+
*
207+
* @param string $username
208+
*
209+
* @return void
210+
*/
211+
public function theAdministratorRetrievesTheInformationOfUserUsingTheOccCommand($username) {
212+
$this->featureContext->invokingTheCommand(
213+
"user:list $username --output=json"
214+
);
215+
}
216+
204217
/**
205218
* @When the administrator sends a group creation request for group :group using the occ command
206219
*
@@ -421,6 +434,20 @@ public function theGroupsReturnedByTheOccCommandShouldBe(TableNode $groupTableNo
421434
}
422435
}
423436

437+
/**
438+
* @Then the display name returned by the occ command should be :displayName
439+
*
440+
* @param string $displayName
441+
*
442+
* @return void
443+
*/
444+
public function theDisplayNameReturnedByTheOccCommandShouldBe($displayName) {
445+
$lastOutput = $this->featureContext->getStdOutOfOccCommand();
446+
$lastOutputUser = \json_decode($lastOutput, true);
447+
$lastOutputDisplayName = \array_column($lastOutputUser, 'displayName')[0];
448+
PHPUnit_Framework_Assert::assertEquals($displayName, $lastOutputDisplayName);
449+
}
450+
424451
/**
425452
* This will run before EVERY scenario.
426453
* It will set the properties for this object.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@cli @skipOnLDAP
2+
Feature: get user
3+
As an admin, subadmin or as myself
4+
I want to be able to retrieve user information
5+
So that I can see the information
6+
7+
Scenario: admin gets an existing user
8+
Given user "brand-new-user" has been created
9+
And user "%admin%" has changed the display name of user "brand-new-user" to "Anne Brown"
10+
When the administrator retrieves the information of user "brand-new-user" using the occ command
11+
Then the command should have been successful
12+
And the display name returned by the occ command should be "Anne Brown"
13+
14+
Scenario: admin tries to get a not existing user
15+
Given user "not-a-user" has been deleted
16+
When the administrator retrieves the information of user "not-a-user" using the occ command
17+
Then the command should have been successful
18+
And the occ command JSON output should be empty

0 commit comments

Comments
 (0)