a557c08f47ff778143be6c91f7c527394e710ecf
[yaffs-website] / web / modules / contrib / devel / webprofiler / tests / src / Kernel / DecoratorTest.php
1 <?php
2
3 namespace Drupal\Tests\webprofiler\Kernel;
4
5 use Drupal\KernelTests\KernelTestBase;
6
7 /**
8  * Class DecoratorTest.
9  *
10  * @group webprofiler
11  */
12 class DecoratorTest extends KernelTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   public static $modules = ['system', 'views'];
18
19   /**
20    * Tests the Entity Type Manager service decoration.
21    *
22    * @param string $service
23    *   The service name.
24    * @param string $original
25    *   The original class.
26    * @param string $decorated
27    *   The decorated class.
28    *
29    * @dataProvider decorators
30    */
31   public function testEntityTypeDecorator($service, $original, $decorated) {
32     $entityTypeManagerOriginal = $this->container->get($service);
33
34     $this->assertInstanceOf($original, $entityTypeManagerOriginal);
35
36     $this->container->get('module_installer')->install(['webprofiler']);
37
38     $entityTypeManagerDecorated = $this->container->get($service);
39
40     $this->assertInstanceOf($decorated, $entityTypeManagerDecorated);
41   }
42
43   /**
44    * DataProvider for testEntityTypeDecorator.
45    *
46    * @return array
47    *   The array of values to run tests on.
48    */
49   public function decorators() {
50     return array(
51       array('entity_type.manager', 'Drupal\Core\Entity\EntityTypeManager', 'Drupal\webprofiler\Entity\EntityManagerWrapper'),
52       array('cache_factory', 'Drupal\Core\Cache\MemoryBackendFactory', 'Drupal\webprofiler\Cache\CacheFactoryWrapper'),
53       array('asset.css.collection_renderer', 'Drupal\Core\Asset\CssCollectionRenderer', 'Drupal\webprofiler\Asset\CssCollectionRendererWrapper'),
54       array('asset.js.collection_renderer', 'Drupal\Core\Asset\JsCollectionRenderer', 'Drupal\webprofiler\Asset\JsCollectionRendererWrapper'),
55       array('state', 'Drupal\Core\State\State', 'Drupal\webprofiler\State\StateWrapper'),
56       array('views.executable', 'Drupal\views\ViewExecutableFactory', 'Drupal\webprofiler\Views\ViewExecutableFactoryWrapper'),
57       array('form_builder', 'Drupal\Core\Form\FormBuilder', 'Drupal\webprofiler\Form\FormBuilderWrapper'),
58       array('access_manager', 'Drupal\Core\Access\AccessManager', 'Drupal\webprofiler\Access\AccessManagerWrapper'),
59       array('theme.negotiator', 'Drupal\Core\Theme\ThemeNegotiator', 'Drupal\webprofiler\Theme\ThemeNegotiatorWrapper'),
60       array('config.factory', 'Drupal\Core\Config\ConfigFactory', 'Drupal\webprofiler\Config\ConfigFactoryWrapper'),
61       array('string_translation', 'Drupal\Core\StringTranslation\TranslationManager', 'Drupal\webprofiler\StringTranslation\TranslationManagerWrapper'),
62     );
63   }
64
65 }