1313
1414use Behat \Behat \Context \Context ;
1515use Behat \Gherkin \Node \TableNode ;
16+ use Behat \Hook \AfterScenario ;
17+ use Behat \Hook \BeforeScenario ;
1618use Behat \Step \Given ;
19+ use Behat \Step \Then ;
1720use Behat \Step \When ;
1821use GuzzleHttp \Client ;
1922use GuzzleHttp \Cookie \CookieJar ;
@@ -60,10 +63,8 @@ public function __construct() {
6063 $ this ->baseUrl = getenv ('TEST_SERVER_URL ' );
6164 }
6265
63- /**
64- * @BeforeScenario
65- * @AfterScenario
66- */
66+ #[BeforeScenario]
67+ #[AfterScenario]
6768 public function cleanUpBetweenTests () {
6869 $ this ->setCurrentUser ('admin ' );
6970 $ this ->sendingTo ('DELETE ' , '/apps/files_accesscontrol_testing ' );
@@ -76,9 +77,7 @@ public function cleanUpBetweenTests() {
7677 }
7778 }
7879
79- /**
80- * @AfterScenario
81- */
80+ #[AfterScenario]
8281 public function tearDown () {
8382 foreach ($ this ->createdUsers as $ user ) {
8483 $ this ->deleteUser ($ user );
@@ -92,9 +91,7 @@ public function tearDown() {
9291 }
9392 }
9493
95- /**
96- * @Given /^Ensure tag exists$/
97- */
94+ #[Given(pattern: 'Ensure tag exists ' )]
9895 public function createTag () {
9996 $ this ->setCurrentUser ('admin ' );
10097 $ this ->sendingTo ('POST ' , '/apps/files_accesscontrol_testing ' );
@@ -105,9 +102,7 @@ public function createTag() {
105102 $ this ->tagId = $ data ['tagId ' ];
106103 }
107104
108- /**
109- * @Given /^user "([^"]*)" tags file "([^"]*)"$/
110- */
105+ #[Given(pattern: '/^user "([^"]*)" tags file "([^"]*)"$/ ' )]
111106 public function tagFile (string $ user , string $ path ) {
112107 // TODO: Remove all created tags?
113108 $ this ->setCurrentUser ($ user );
@@ -117,9 +112,7 @@ public function tagFile(string $user, string $path) {
117112 $ this ->assertStatusCode ($ this ->response , 200 );
118113 }
119114
120- /**
121- * @Given /^user "([^"]*)" creates (global|user) flow with (\d+)$/
122- */
115+ #[Given(pattern: '/^user "([^"]*)" creates (global|user) flow with (\d+)$/ ' )]
123116 public function createFlow (string $ user , string $ scope , int $ statusCode , TableNode $ tableNode ) {
124117 $ this ->setCurrentUser ($ user );
125118
@@ -140,9 +133,7 @@ public function createFlow(string $user, string $scope, int $statusCode, TableNo
140133 Assert::assertSame ($ statusCode , $ this ->response ->getStatusCode (), 'HTTP status code mismatch: ' . "\n" . $ this ->response ->getBody ()->getContents ());
141134 }
142135
143- /**
144- * @Given /^user "([^"]*)" shares file "([^"]*)" with user "([^"]*)"$/
145- */
136+ #[Given(pattern: '/^user "([^"]*)" shares file "([^"]*)" with user "([^"]*)"$/ ' )]
146137 public function userSharesFile (string $ sharer , string $ file , string $ sharee ): void {
147138 $ this ->setCurrentUser ($ sharer );
148139 $ this ->sendingToWith ('POST ' , '/apps/files_sharing/api/v1/shares ' , [
@@ -153,9 +144,7 @@ public function userSharesFile(string $sharer, string $file, string $sharee): vo
153144 ]);
154145 }
155146
156- /**
157- * @Given /^user "([^"]*)" shares file "([^"]*)" publicly$/
158- */
147+ #[Given(pattern: '/^user "([^"]*)" shares file "([^"]*)" publicly$/ ' )]
159148 public function userSharesFilePublicly (string $ sharer , string $ file ): void {
160149 $ this ->setCurrentUser ($ sharer );
161150 $ this ->sendingToWith ('POST ' , '/apps/files_sharing/api/v1/shares ' , [
@@ -178,12 +167,8 @@ public function createGroupFolderForGroup(string $folder, string $group): void {
178167 }
179168
180169 // ChecksumsContext
181- /**
182- * @Then The webdav response should have a status code :statusCode
183- * @param string $statusCode
184- * @throws \Exception
185- */
186- public function theWebdavResponseShouldHaveAStatusCode ($ statusCode ) {
170+ #[Then(pattern: 'The webdav response should have a status code :statusCode ' )]
171+ public function theWebdavResponseShouldHaveAStatusCode (string $ statusCode ) {
187172 if (str_contains ($ statusCode , '| ' )) {
188173 $ statusCodes = array_map ('intval ' , explode ('| ' , $ statusCode ));
189174 } else {
@@ -195,7 +180,7 @@ public function theWebdavResponseShouldHaveAStatusCode($statusCode) {
195180 }
196181
197182
198- #[\ Behat \ Step \ Given('the following :appId app config is set ' )]
183+ #[Given('the following :appId app config is set ' )]
199184 public function setAppConfig (string $ appId , TableNode $ formData ): void {
200185 $ this ->setCurrentUser ('admin ' );
201186 foreach ($ formData ->getRows () as $ row ) {
@@ -209,21 +194,14 @@ public function setAppConfig(string $appId, TableNode $formData): void {
209194 /**
210195 * User management
211196 */
212-
213- /**
214- * @Given /^as user "([^"]*)"$/
215- * @param string $user
216- */
197+ #[Given('/^as user "([^"]*)"$/ ' )]
217198 public function setCurrentUser (string $ user ): string {
218199 $ before = $ this ->currentUser ;
219200 $ this ->currentUser = $ user ;
220201 return $ before ?? 'admin ' ;
221202 }
222203
223- /**
224- * @Given /^user "([^"]*)" exists$/
225- * @param string $user
226- */
204+ #[Given('/^user "([^"]*)" exists$/ ' )]
227205 public function assureUserExists (string $ user ): void {
228206 try {
229207 $ this ->userExists ($ user );
@@ -343,22 +321,12 @@ public function addingUserToGroup(string $user, string $group): void {
343321 * Requests
344322 */
345323
346- /**
347- * @When /^sending "([^"]*)" to "([^"]*)"$/
348- * @param string $verb
349- * @param string $url
350- */
324+ #[When(pattern: '/^sending "([^"]*)" to "([^"]*)"$/ ' )]
351325 public function sendingTo (string $ verb , string $ url ): void {
352- $ this ->sendingToWith ($ verb , $ url, null );
326+ $ this ->sendingToWith ($ verb , $ url );
353327 }
354328
355- /**
356- * @When /^sending "([^"]*)" to "([^"]*)" with$/
357- * @param string $verb
358- * @param string $url
359- * @param array|null $body
360- * @param array $headers
361- */
329+ #[When(pattern: '/^sending "([^"]*)" to "([^"]*)" with$/ ' )]
362330 public function sendingToWith (string $ verb , string $ url , ?array $ body = null , array $ headers = []): void {
363331 $ fullUrl = $ this ->baseUrl . 'ocs/v2.php ' . $ url ;
364332 $ client = new Client ();
@@ -388,10 +356,6 @@ public function sendingToWith(string $verb, string $url, ?array $body = null, ar
388356 }
389357 }
390358
391- /**
392- * @param ResponseInterface $response
393- * @param int $statusCode
394- */
395359 protected function assertStatusCode (ResponseInterface $ response , int $ statusCode ): void {
396360 Assert::assertEquals ($ statusCode , $ response ->getStatusCode ());
397361 }
0 commit comments