[$discovery_path]]); $this->assertEquals([ 'discovery_test_1' => [ 'id' => 'discovery_test_1', 'class' => 'com\example\PluginNamespace\DiscoveryTest1', ], ], $discovery->getDefinitions()); // Gain access to the file cache so we can change it. $ref_file_cache = new \ReflectionProperty($discovery, 'fileCache'); $ref_file_cache->setAccessible(TRUE); /* @var $file_cache \Drupal\Component\FileCache\FileCacheInterface */ $file_cache = $ref_file_cache->getValue($discovery); // The file cache is keyed by the file path, and we'll add some known // content to test against. $file_cache->set($file_path, [ 'id' => 'wrong_id', 'content' => serialize(['an' => 'array']), ]); // Now perform the same query and check for the cached results. $this->assertEquals([ 'wrong_id' => [ 'an' => 'array', ], ], $discovery->getDefinitions()); } }