Mercurial > hg > isophonics-drupal-site
comparison core/modules/system/tests/src/Kernel/PathHooksTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | af1871eacc83 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\system\Kernel; | |
4 | |
5 use Drupal\Core\Language\LanguageInterface; | |
6 use Drupal\Core\Path\AliasManagerInterface; | |
7 use Drupal\KernelTests\KernelTestBase; | |
8 use Prophecy\Argument; | |
9 | |
10 /** | |
11 * @group Drupal | |
12 */ | |
13 class PathHooksTest extends KernelTestBase { | |
14 | |
15 /** | |
16 * {@inheritdoc} | |
17 */ | |
18 static public $modules = ['system']; | |
19 | |
20 /** | |
21 * Test system_path_*() correctly clears caches. | |
22 */ | |
23 public function testPathHooks() { | |
24 $source = '/' . $this->randomMachineName(); | |
25 $alias = '/' . $this->randomMachineName(); | |
26 | |
27 // Check system_path_insert(); | |
28 $alias_manager = $this->prophesize(AliasManagerInterface::class); | |
29 $alias_manager->cacheClear(Argument::any())->shouldBeCalledTimes(1); | |
30 $alias_manager->cacheClear($source)->shouldBeCalledTimes(1); | |
31 \Drupal::getContainer()->set('path.alias_manager', $alias_manager->reveal()); | |
32 $alias_storage = \Drupal::service('path.alias_storage'); | |
33 $alias_storage->save($source, $alias); | |
34 | |
35 $new_source = '/' . $this->randomMachineName(); | |
36 $path = $alias_storage->load(['source' => $source]); | |
37 | |
38 // Check system_path_update(); | |
39 $alias_manager = $this->prophesize(AliasManagerInterface::class); | |
40 $alias_manager->cacheClear(Argument::any())->shouldBeCalledTimes(2); | |
41 $alias_manager->cacheClear($source)->shouldBeCalledTimes(1); | |
42 $alias_manager->cacheClear($new_source)->shouldBeCalledTimes(1); | |
43 \Drupal::getContainer()->set('path.alias_manager', $alias_manager->reveal()); | |
44 $alias_storage->save($new_source, $alias, LanguageInterface::LANGCODE_NOT_SPECIFIED, $path['pid']); | |
45 | |
46 // Check system_path_delete(); | |
47 $alias_manager = $this->prophesize(AliasManagerInterface::class); | |
48 $alias_manager->cacheClear(Argument::any())->shouldBeCalledTimes(1); | |
49 $alias_manager->cacheClear($new_source)->shouldBeCalledTimes(1); | |
50 \Drupal::getContainer()->set('path.alias_manager', $alias_manager->reveal()); | |
51 $alias_storage->delete(['pid' => $path['pid']]); | |
52 | |
53 } | |
54 | |
55 } |