public function RemoteUrlTest::testRemotePreSave in Entity Share 8.3
Same name and namespace in other branches
- 8.2 modules/entity_share_client/tests/src/Kernel/RemoteUrlTest.php \Drupal\Tests\entity_share_client\Kernel\RemoteUrlTest::testRemotePreSave()
Tests that trailing slash is removed from url.
File
- modules/
entity_share_client/ tests/ src/ Kernel/ RemoteUrlTest.php, line 54
Class
- RemoteUrlTest
- Tests remote url.
Namespace
Drupal\Tests\entity_share_client\KernelCode
public function testRemotePreSave() {
$remote_storage = $this->entityTypeManager
->getStorage('remote');
$plugin = $this->authPluginManager
->createInstance('basic_auth');
$configuration = $plugin
->getConfiguration();
$remote = $remote_storage
->create([
'id' => $this
->randomMachineName(),
'label' => $this
->randomString(),
'url' => 'http://example.com',
]);
$credentials = [];
$credentials['username'] = 'test';
$credentials['password'] = 'test';
$this->keyValueStore
->set($configuration['uuid'], $credentials);
$key = $configuration['uuid'];
$configuration['data'] = [
'credential_provider' => 'entity_share',
'storage_key' => $key,
];
$plugin
->setConfiguration($configuration);
$remote
->mergePluginConfig($plugin);
$remote
->save();
$this
->assertEquals($remote
->get('url'), 'http://example.com');
$remote
->set('url', 'http://example.com/');
$remote
->save();
$this
->assertEquals($remote
->get('url'), 'http://example.com');
$remote
->set('url', 'http://example.com/subdirectory');
$remote
->save();
$this
->assertEquals($remote
->get('url'), 'http://example.com/subdirectory');
$remote
->set('url', 'http://example.com/subdirectory/');
$remote
->save();
$this
->assertEquals($remote
->get('url'), 'http://example.com/subdirectory');
}