@@ -1583,12 +1583,6 @@ public function testValidateExpirationDateInternalEnforceValid($shareType): void
15831583 ]);
15841584 }
15851585
1586- $ hookListener = $ this ->createMock (DummyShareManagerListener::class);
1587- Util::connectHook ('\OC\Share ' , 'verifyExpirationDate ' , $ hookListener , 'listener ' );
1588- $ hookListener ->expects ($ this ->once ())->method ('listener ' )->with ($ this ->callback (function ($ data ) use ($ future ) {
1589- return $ data ['expirationDate ' ] == $ future ;
1590- }));
1591-
15921586 self ::invokePrivate ($ this ->manager , 'validateExpirationDateInternal ' , [$ share ]);
15931587
15941588 $ this ->assertEquals ($ expected , $ share ->getExpirationDate ());
@@ -1607,24 +1601,13 @@ public function testValidateExpirationDateInternalNoDefault($shareType): void {
16071601 $ share ->setShareType ($ shareType );
16081602 $ share ->setExpirationDate ($ date );
16091603
1610- $ hookListener = $ this ->createMock (DummyShareManagerListener::class);
1611- Util::connectHook ('\OC\Share ' , 'verifyExpirationDate ' , $ hookListener , 'listener ' );
1612- $ hookListener ->expects ($ this ->once ())->method ('listener ' )->with ($ this ->callback (function ($ data ) use ($ expected ) {
1613- return $ data ['expirationDate ' ] == $ expected && $ data ['passwordSet ' ] === false ;
1614- }));
1615-
16161604 self ::invokePrivate ($ this ->manager , 'validateExpirationDateInternal ' , [$ share ]);
16171605
16181606 $ this ->assertEquals ($ expected , $ share ->getExpirationDate ());
16191607 }
16201608
16211609 #[DataProvider('validateExpirationDateInternalProvider ' )]
16221610 public function testValidateExpirationDateInternalNoDateNoDefault ($ shareType ): void {
1623- $ hookListener = $ this ->createMock (DummyShareManagerListener::class);
1624- Util::connectHook ('\OC\Share ' , 'verifyExpirationDate ' , $ hookListener , 'listener ' );
1625- $ hookListener ->expects ($ this ->once ())->method ('listener ' )->with ($ this ->callback (function ($ data ) {
1626- return $ data ['expirationDate ' ] === null && $ data ['passwordSet ' ] === true ;
1627- }));
16281611
16291612 $ share = $ this ->manager ->newShare ();
16301613 $ share ->setShareType ($ shareType );
@@ -1661,12 +1644,6 @@ public function testValidateExpirationDateInternalNoDateDefault($shareType): voi
16611644 ]);
16621645 }
16631646
1664- $ hookListener = $ this ->createMock (DummyShareManagerListener::class);
1665- Util::connectHook ('\OC\Share ' , 'verifyExpirationDate ' , $ hookListener , 'listener ' );
1666- $ hookListener ->expects ($ this ->once ())->method ('listener ' )->with ($ this ->callback (function ($ data ) use ($ expected ) {
1667- return $ data ['expirationDate ' ] == $ expected ;
1668- }));
1669-
16701647 self ::invokePrivate ($ this ->manager , 'validateExpirationDateInternal ' , [$ share ]);
16711648
16721649 $ this ->assertEquals ($ expected , $ share ->getExpirationDate ());
@@ -1701,64 +1678,11 @@ public function testValidateExpirationDateInternalDefault($shareType): void {
17011678 ]);
17021679 }
17031680
1704- $ hookListener = $ this ->createMock (DummyShareManagerListener::class);
1705- Util::connectHook ('\OC\Share ' , 'verifyExpirationDate ' , $ hookListener , 'listener ' );
1706- $ hookListener ->expects ($ this ->once ())->method ('listener ' )->with ($ this ->callback (function ($ data ) use ($ expected ) {
1707- return $ data ['expirationDate ' ] == $ expected ;
1708- }));
1709-
17101681 self ::invokePrivate ($ this ->manager , 'validateExpirationDateInternal ' , [$ share ]);
17111682
17121683 $ this ->assertEquals ($ expected , $ share ->getExpirationDate ());
17131684 }
17141685
1715- #[DataProvider('validateExpirationDateInternalProvider ' )]
1716- public function testValidateExpirationDateInternalHookModification ($ shareType ): void {
1717- $ nextWeek = new \DateTime ('now ' , $ this ->timezone );
1718- $ nextWeek ->add (new \DateInterval ('P7D ' ));
1719- $ nextWeek ->setTime (23 , 59 , 59 );
1720-
1721- $ save = clone $ nextWeek ;
1722-
1723- $ hookListener = $ this ->createMock (DummyShareManagerListener::class);
1724- Util::connectHook ('\OC\Share ' , 'verifyExpirationDate ' , $ hookListener , 'listener ' );
1725- $ hookListener ->expects ($ this ->once ())->method ('listener ' )->willReturnCallback (function ($ data ): void {
1726- $ data ['expirationDate ' ]->sub (new \DateInterval ('P2D ' ));
1727- });
1728-
1729- $ share = $ this ->manager ->newShare ();
1730- $ share ->setShareType ($ shareType );
1731- $ share ->setExpirationDate ($ nextWeek );
1732-
1733- self ::invokePrivate ($ this ->manager , 'validateExpirationDateInternal ' , [$ share ]);
1734-
1735- $ save ->sub (new \DateInterval ('P2D ' ));
1736- $ this ->assertEquals ($ save , $ share ->getExpirationDate ());
1737- }
1738-
1739- #[DataProvider('validateExpirationDateInternalProvider ' )]
1740- public function testValidateExpirationDateInternalHookException ($ shareType ): void {
1741- $ this ->expectException (\Exception::class);
1742- $ this ->expectExceptionMessage ('Invalid date! ' );
1743-
1744- $ nextWeek = new \DateTime ();
1745- $ nextWeek ->add (new \DateInterval ('P7D ' ));
1746- $ nextWeek ->setTime (23 , 59 , 59 );
1747-
1748- $ share = $ this ->manager ->newShare ();
1749- $ share ->setShareType ($ shareType );
1750- $ share ->setExpirationDate ($ nextWeek );
1751-
1752- $ hookListener = $ this ->createMock (DummyShareManagerListener::class);
1753- Util::connectHook ('\OC\Share ' , 'verifyExpirationDate ' , $ hookListener , 'listener ' );
1754- $ hookListener ->expects ($ this ->once ())->method ('listener ' )->willReturnCallback (function ($ data ): void {
1755- $ data ['accepted ' ] = false ;
1756- $ data ['message ' ] = 'Invalid date! ' ;
1757- });
1758-
1759- self ::invokePrivate ($ this ->manager , 'validateExpirationDateInternal ' , [$ share ]);
1760- }
1761-
17621686 #[DataProvider('validateExpirationDateInternalProvider ' )]
17631687 public function testValidateExpirationDateInternalExistingShareNoDefault ($ shareType ): void {
17641688 $ share = $ this ->manager ->newShare ();
@@ -1924,12 +1848,6 @@ public function testValidateExpirationDateEnforceValid(): void {
19241848 ['core ' , 'shareapi_enforce_expire_date ' , true ],
19251849 ]);
19261850
1927- $ hookListener = $ this ->createMock (DummyShareManagerListener::class);
1928- Util::connectHook ('\OC\Share ' , 'verifyExpirationDate ' , $ hookListener , 'listener ' );
1929- $ hookListener ->expects ($ this ->once ())->method ('listener ' )->with ($ this ->callback (function ($ data ) use ($ future ) {
1930- return $ data ['expirationDate ' ] == $ future ;
1931- }));
1932-
19331851 self ::invokePrivate ($ this ->manager , 'validateExpirationDateLink ' , [$ share ]);
19341852
19351853 $ this ->assertEquals ($ expected , $ share ->getExpirationDate ());
@@ -1947,23 +1865,12 @@ public function testValidateExpirationDateNoDefault(): void {
19471865 $ share = $ this ->manager ->newShare ();
19481866 $ share ->setExpirationDate ($ date );
19491867
1950- $ hookListener = $ this ->createMock (DummyShareManagerListener::class);
1951- Util::connectHook ('\OC\Share ' , 'verifyExpirationDate ' , $ hookListener , 'listener ' );
1952- $ hookListener ->expects ($ this ->once ())->method ('listener ' )->with ($ this ->callback (function ($ data ) use ($ expected ) {
1953- return $ data ['expirationDate ' ] == $ expected && $ data ['passwordSet ' ] === false ;
1954- }));
1955-
19561868 self ::invokePrivate ($ this ->manager , 'validateExpirationDateLink ' , [$ share ]);
19571869
19581870 $ this ->assertEquals ($ expected , $ share ->getExpirationDate ());
19591871 }
19601872
19611873 public function testValidateExpirationDateNoDateNoDefault (): void {
1962- $ hookListener = $ this ->createMock (DummyShareManagerListener::class);
1963- Util::connectHook ('\OC\Share ' , 'verifyExpirationDate ' , $ hookListener , 'listener ' );
1964- $ hookListener ->expects ($ this ->once ())->method ('listener ' )->with ($ this ->callback (function ($ data ) {
1965- return $ data ['expirationDate ' ] === null && $ data ['passwordSet ' ] === true ;
1966- }));
19671874
19681875 $ share = $ this ->manager ->newShare ();
19691876 $ share ->setPassword ('password ' );
@@ -1993,12 +1900,6 @@ public function testValidateExpirationDateNoDateDefault(): void {
19931900 ['core ' , 'shareapi_enforce_expire_date ' , false ],
19941901 ]);
19951902
1996- $ hookListener = $ this ->createMock (DummyShareManagerListener::class);
1997- Util::connectHook ('\OC\Share ' , 'verifyExpirationDate ' , $ hookListener , 'listener ' );
1998- $ hookListener ->expects ($ this ->once ())->method ('listener ' )->with ($ this ->callback (function ($ data ) use ($ expected ) {
1999- return $ data ['expirationDate ' ] == $ expected ;
2000- }));
2001-
20021903 self ::invokePrivate ($ this ->manager , 'validateExpirationDateLink ' , [$ share ]);
20031904
20041905 $ this ->assertEquals ($ expected , $ share ->getExpirationDate ());
@@ -2028,12 +1929,6 @@ public function testValidateExpirationDateDefault(): void {
20281929 ['core ' , 'shareapi_enforce_expire_date ' , false ],
20291930 ]);
20301931
2031- $ hookListener = $ this ->createMock (DummyShareManagerListener::class);
2032- Util::connectHook ('\OC\Share ' , 'verifyExpirationDate ' , $ hookListener , 'listener ' );
2033- $ hookListener ->expects ($ this ->once ())->method ('listener ' )->with ($ this ->callback (function ($ data ) use ($ expected ) {
2034- return $ data ['expirationDate ' ] == $ expected ;
2035- }));
2036-
20371932 self ::invokePrivate ($ this ->manager , 'validateExpirationDateLink ' , [$ share ]);
20381933
20391934 $ this ->assertEquals ($ expected , $ share ->getExpirationDate ());
@@ -2064,61 +1959,11 @@ public function testValidateExpirationNegativeOffsetTimezone(): void {
20641959 ['core ' , 'shareapi_enforce_expire_date ' , false ],
20651960 ]);
20661961
2067- $ hookListener = $ this ->createMock (DummyShareManagerListener::class);
2068- Util::connectHook ('\OC\Share ' , 'verifyExpirationDate ' , $ hookListener , 'listener ' );
2069- $ hookListener ->expects ($ this ->once ())->method ('listener ' )->with ($ this ->callback (function ($ data ) use ($ expected ) {
2070- return $ data ['expirationDate ' ] == $ expected ;
2071- }));
2072-
20731962 self ::invokePrivate ($ this ->manager , 'validateExpirationDateLink ' , [$ share ]);
20741963
20751964 $ this ->assertEquals ($ expected , $ share ->getExpirationDate ());
20761965 }
20771966
2078- public function testValidateExpirationDateHookModification (): void {
2079- $ nextWeek = new \DateTime ('now ' , $ this ->timezone );
2080- $ nextWeek ->add (new \DateInterval ('P7D ' ));
2081-
2082- $ save = clone $ nextWeek ;
2083- $ save ->setTime (23 , 59 , 59 );
2084- $ save ->sub (new \DateInterval ('P2D ' ));
2085- $ save ->setTimezone (new \DateTimeZone (date_default_timezone_get ()));
2086-
2087- $ hookListener = $ this ->createMock (DummyShareManagerListener::class);
2088- Util::connectHook ('\OC\Share ' , 'verifyExpirationDate ' , $ hookListener , 'listener ' );
2089- $ hookListener ->expects ($ this ->once ())->method ('listener ' )->willReturnCallback (function ($ data ): void {
2090- $ data ['expirationDate ' ]->sub (new \DateInterval ('P2D ' ));
2091- });
2092-
2093- $ share = $ this ->manager ->newShare ();
2094- $ share ->setExpirationDate ($ nextWeek );
2095-
2096- self ::invokePrivate ($ this ->manager , 'validateExpirationDateLink ' , [$ share ]);
2097-
2098- $ this ->assertEquals ($ save , $ share ->getExpirationDate ());
2099- }
2100-
2101- public function testValidateExpirationDateHookException (): void {
2102- $ this ->expectException (\Exception::class);
2103- $ this ->expectExceptionMessage ('Invalid date! ' );
2104-
2105- $ nextWeek = new \DateTime ();
2106- $ nextWeek ->add (new \DateInterval ('P7D ' ));
2107- $ nextWeek ->setTime (23 , 59 , 59 );
2108-
2109- $ share = $ this ->manager ->newShare ();
2110- $ share ->setExpirationDate ($ nextWeek );
2111-
2112- $ hookListener = $ this ->createMock (DummyShareManagerListener::class);
2113- Util::connectHook ('\OC\Share ' , 'verifyExpirationDate ' , $ hookListener , 'listener ' );
2114- $ hookListener ->expects ($ this ->once ())->method ('listener ' )->willReturnCallback (function ($ data ): void {
2115- $ data ['accepted ' ] = false ;
2116- $ data ['message ' ] = 'Invalid date! ' ;
2117- });
2118-
2119- self ::invokePrivate ($ this ->manager , 'validateExpirationDateLink ' , [$ share ]);
2120- }
2121-
21221967 public function testValidateExpirationDateExistingShareNoDefault (): void {
21231968 $ share = $ this ->manager ->newShare ();
21241969
0 commit comments