Unverified Commit d6d4d9cd authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3540525 by andypost: Remove remaining usage of setAccessible()

(cherry picked from commit 967e3af6)
parent de03f6e2
Loading
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -64,7 +64,6 @@ public function testGetDefinitions(): void {

    // Gain access to the file cache.
    $ref_file_cache = new \ReflectionProperty($discovery, 'fileCache');
    $ref_file_cache->setAccessible(TRUE);
    /** @var \Drupal\Component\FileCache\FileCacheInterface $file_cache */
    $file_cache = $ref_file_cache->getValue($discovery);

@@ -122,7 +121,6 @@ public function testGetDefinitionsMissingTrait(): void {

    // Gain access to the file cache.
    $ref_file_cache = new \ReflectionProperty($discovery, 'fileCache');
    $ref_file_cache->setAccessible(TRUE);
    /** @var \Drupal\Component\FileCache\FileCacheInterface $file_cache */
    $file_cache = $ref_file_cache->getValue($discovery);

+0 −1
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ public function testGetPluginNamespaces(): void {
    $discovery = new AttributeClassDiscovery(['com/example' => [__DIR__]]);

    $reflection = new \ReflectionMethod($discovery, 'getPluginNamespaces');
    $reflection->setAccessible(TRUE);

    $result = $reflection->invoke($discovery);
    $this->assertEquals(['com/example' => [__DIR__]], $result);
+0 −1
Original line number Diff line number Diff line
@@ -97,7 +97,6 @@ protected function setUp(): void {
   */
  protected function setUpAccessCache(EntityAccessControlHandler $handler, bool $in_cache, string $cid): \ReflectionProperty {
    $access_cache = new \ReflectionProperty($handler, 'accessCache');
    $access_cache->setAccessible(TRUE);

    $cache = [];
    if ($in_cache) {
+0 −1
Original line number Diff line number Diff line
@@ -72,7 +72,6 @@ protected function setUp(): void {

    $this->discovery = $this->prophesize(DiscoveryInterface::class);
    $property = new \ReflectionProperty(FieldTypePluginManager::class, 'discovery');
    $property->setAccessible(TRUE);
    $property->setValue($this->fieldTypeManager, $this->discovery->reveal());
  }

+0 −7
Original line number Diff line number Diff line
@@ -644,7 +644,6 @@ public function testGetFilesFromSourcesPath(array $sources, array $expected = []
   */
  public function testGetFilesFromPathEmptyWarning(): void {
    $method = new \ReflectionMethod(IconFinder::class, 'getFilesFromPath');
    $method->setAccessible(TRUE);

    $this->logger->expects($this->once())
      ->method('warning')
@@ -658,7 +657,6 @@ public function testGetFilesFromPathEmptyWarning(): void {
   */
  public function testGetFilesFromPathInvalidExtensionWarning(): void {
    $method = new \ReflectionMethod(IconFinder::class, 'getFilesFromPath');
    $method->setAccessible(TRUE);

    $this->logger->expects($this->once())
      ->method('warning');
@@ -671,7 +669,6 @@ public function testGetFilesFromPathInvalidExtensionWarning(): void {
   */
  public function testGetFileFromUrlWarning(): void {
    $method = new \ReflectionMethod(IconFinder::class, 'getFileFromUrl');
    $method->setAccessible(TRUE);

    $this->logger->expects($this->once())
      ->method('warning')
@@ -685,7 +682,6 @@ public function testGetFileFromUrlWarning(): void {
   */
  public function testFindFilesWarning(): void {
    $method = new \ReflectionMethod(IconFinder::class, 'findFiles');
    $method->setAccessible(TRUE);

    $this->logger->expects($this->once())
      ->method('warning')
@@ -699,7 +695,6 @@ public function testFindFilesWarning(): void {
   */
  public function testFindFilesEmptyWarning(): void {
    $method = new \ReflectionMethod(IconFinder::class, 'findFiles');
    $method->setAccessible(TRUE);

    $this->logger->expects($this->once())
      ->method('warning');
@@ -765,7 +760,6 @@ public static function providerExtractIconIdFromFilename(): iterable {
   */
  public function testExtractIconIdFromFilename(string $filename, string $filename_pattern, string $expected): void {
    $method = new \ReflectionMethod(IconFinder::class, 'extractIconIdFromFilename');
    $method->setAccessible(TRUE);

    $this->assertEquals($expected, $method->invoke($this->iconFinder, $filename, $filename_pattern));
  }
@@ -775,7 +769,6 @@ public function testExtractIconIdFromFilename(string $filename, string $filename
   */
  public function testExtractIconIdFromFilenameWarning(): void {
    $method = new \ReflectionMethod(IconFinder::class, 'extractIconIdFromFilename');
    $method->setAccessible(TRUE);

    // PHPUnit 10 cannot expect warnings, so we have to catch them ourselves.
    // Thanks to: Drupal\Tests\Component\PhpStorage\FileStorageTest.