@@ -2695,32 +2695,8 @@ public function userExpiresTheLastShareOfResourceInsideOfTheSpace(
2695
2695
string $ resource ,
2696
2696
string $ spaceName
2697
2697
): void {
2698
- $ dateTime = new DateTime ('yesterday ' );
2699
- $ rows ['expireDate ' ] = $ dateTime ->format ('Y-m-d \\TH:i:sP ' );
2700
- if ($ this ->featureContext ->isUsingSharingNG ()) {
2701
- $ space = $ this ->getSpaceByName ($ user , $ spaceName );
2702
- $ itemId = $ this ->getResourceId ($ user , $ spaceName , $ resource );
2703
- $ body ['expirationDateTime ' ] = $ rows ['expireDate ' ];
2704
- $ permissionID = $ this ->featureContext ->shareNgGetLastCreatedUserGroupShareID ();
2705
- $ response = GraphHelper::updateShare (
2706
- $ this ->featureContext ->getBaseUrl (),
2707
- $ this ->featureContext ->getStepLineRef (),
2708
- $ user ,
2709
- $ this ->featureContext ->getPasswordForUser ($ user ),
2710
- $ space ["id " ],
2711
- $ itemId ,
2712
- \json_encode ($ body ),
2713
- $ permissionID
2714
- );
2715
-
2716
- if ($ response ->getStatusCode () === 200 ) {
2717
- $ this ->featureContext ->shareNgAddToCreatedUserGroupShares ($ response );
2718
- }
2719
- $ this ->featureContext ->setResponse ($ response );
2720
- } else {
2721
- $ rows ['permissions ' ] = (string )$ this ->featureContext ->getLastCreatedUserGroupShare ()->permissions ;
2722
- $ this ->featureContext ->setResponse ($ this ->updateSharedResource ($ user , $ rows ));
2723
- }
2698
+ $ response = $ this ->expireResourceShare ($ user , $ resource , $ spaceName );
2699
+ $ this ->featureContext ->setResponse ($ response );
2724
2700
}
2725
2701
2726
2702
/**
@@ -4829,4 +4805,59 @@ public function userHasExpiredTheMembershipOfUserFromSpace(
4829
4805
$ rows ['shareWith ' ] = $ memberUser ;
4830
4806
$ this ->featureContext ->setResponse ($ this ->shareSpace ($ user , $ spaceName , $ rows ));
4831
4807
}
4808
+
4809
+ /**
4810
+ * @param string $user
4811
+ * @param string $resource
4812
+ * @param string $spaceName
4813
+ *
4814
+ * @return ResponseInterface
4815
+ * @throws GuzzleException|JsonException
4816
+ */
4817
+ public function expireResourceShare (string $ user , string $ resource , string $ spaceName ): ResponseInterface {
4818
+ $ rows ['expireDate ' ] = $ this ->featureContext ->formatExpiryDateTime ('Y-m-d \\TH:i:sP ' );
4819
+ if ($ this ->featureContext ->isUsingSharingNG ()) {
4820
+ $ space = $ this ->getSpaceByName ($ user , $ spaceName );
4821
+ $ itemId = $ this ->getResourceId ($ user , $ spaceName , $ resource );
4822
+ $ body ['expirationDateTime ' ] = $ rows ['expireDate ' ];
4823
+ $ permissionID = $ this ->featureContext ->shareNgGetLastCreatedUserGroupShareID ();
4824
+ $ response = GraphHelper::updateShare (
4825
+ $ this ->featureContext ->getBaseUrl (),
4826
+ $ this ->featureContext ->getStepLineRef (),
4827
+ $ user ,
4828
+ $ this ->featureContext ->getPasswordForUser ($ user ),
4829
+ $ space ["id " ],
4830
+ $ itemId ,
4831
+ \json_encode ($ body ),
4832
+ $ permissionID
4833
+ );
4834
+
4835
+ if ($ response ->getStatusCode () === 200 ) {
4836
+ $ this ->featureContext ->shareNgAddToCreatedUserGroupShares ($ response );
4837
+ }
4838
+ return $ response ;
4839
+ } else {
4840
+ $ rows ['permissions ' ] = (string )$ this ->featureContext ->getLastCreatedUserGroupShare ()->permissions ;
4841
+ return $ this ->updateSharedResource ($ user , $ rows );
4842
+ }
4843
+ }
4844
+
4845
+ /**
4846
+ * @Given user :user has expired the last share of resource :resource inside of the space :spaceName
4847
+ *
4848
+ * @param string $user
4849
+ * @param string $resource
4850
+ * @param string $spaceName
4851
+ *
4852
+ * @return void
4853
+ * @throws GuzzleException|JsonException
4854
+ */
4855
+ public function userHasExpiredTheLastShareOfResourceInsideOfTheSpace (
4856
+ string $ user ,
4857
+ string $ resource ,
4858
+ string $ spaceName
4859
+ ): void {
4860
+ $ response = $ this ->expireResourceShare ($ user , $ resource , $ spaceName );
4861
+ $ this ->featureContext ->theHTTPStatusCodeShouldBe (200 , "" , $ response );
4862
+ }
4832
4863
}
0 commit comments