RemoteUrlTest.php in Entity Share 8.2
File
modules/entity_share_client/tests/src/Kernel/RemoteUrlTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\entity_share_client\Kernel;
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
class RemoteUrlTest extends EntityKernelTestBase {
public static $modules = [
'serialization',
'jsonapi',
'entity_share_client',
];
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('remote');
}
public function testRemotePreSave() {
$remote_storage = $this->entityTypeManager
->getStorage('remote');
$remote = $remote_storage
->create([
'id' => $this
->randomMachineName(),
'label' => $this
->randomString(),
'url' => 'http://example.com',
'basic_auth_username' => 'test',
'basic_auth_password' => 'test',
]);
$remote
->save();
$this
->assertEqual($remote
->get('url'), 'http://example.com');
$remote
->set('url', 'http://example.com/');
$remote
->save();
$this
->assertEqual($remote
->get('url'), 'http://example.com');
$remote
->set('url', 'http://example.com/subdirectory');
$remote
->save();
$this
->assertEqual($remote
->get('url'), 'http://example.com/subdirectory');
$remote
->set('url', 'http://example.com/subdirectory/');
$remote
->save();
$this
->assertEqual($remote
->get('url'), 'http://example.com/subdirectory');
}
}