createPolicy(); $sut->checkSecurity([], [], []); $this->expectNotToPerformAssertions(); } public function testCheckPropertyAllowed(): void { $sut = $this->createPolicy(); $sut->checkPropertyAllowed(new \stdClass(), 'foo'); $this->expectNotToPerformAssertions(); } #[DataProvider('getCheckMethodAllowedData')] public function testCheckMethodAllowed(object $obj, string $method, ?string $expectedExceptionMessage = null): void { $sut = $this->createPolicy(); if ($expectedExceptionMessage !== null) { $this->expectException(SecurityNotAllowedMethodError::class); $this->expectExceptionMessage($expectedExceptionMessage); } $sut->checkMethodAllowed($obj, $method); if ($expectedExceptionMessage === null) { $this->expectNotToPerformAssertions(); } } public static function getCheckMethodAllowedData(): array { return [ [new ServerBag(), 'get', 'Tried to access server environment'], [self::createStub(SessionInterface::class), 'getId', 'Tried to access session'], [new \stdClass(), 'foo', 'Tried to access non-read method'], [new \stdClass(), 'setFoo', 'Tried to access non-read method'], [new \stdClass(), 'getFoo'], [new \stdClass(), 'hasFoo'], [new \stdClass(), 'isFoo'], [new UnicodeString(), '__toString'], // Request [new Request(), 'get', null], [new Request(), 'isXmlHttpRequest', 'Tried to call setter() of app variable'], [new Request(), 'hasSession', 'Tried to call setter() of app variable'], // PdfContext [new PdfContext(), 'setOption'], [new PdfContext(), 'getOption', 'Tried to access forbidden method on PdfContext'], // AppVariable [new AppVariable(), 'getRequest'], [new AppVariable(), 'getUser'], [new AppVariable(), 'getLocale'], [new AppVariable(), 'getCharset', 'Tried to access forbidden app variable method'], // User [new User(), 'getUsername'], [new User(), 'getPassword', 'Tried to access user secrets'], [new User(), 'getTotpSecret', 'Tried to access user secrets'], [new User(), 'getPlainPassword', 'Tried to access user secrets'], [new User(), 'getConfirmationToken', 'Tried to access user secrets'], [new User(), 'getTotpAuthenticationConfiguration', 'Tried to access user secrets'], [new User(), 'getPlainApiToken', 'Tried to access user secrets'], [new User(), 'getApiToken', 'Tried to access user secrets'], ]; } }