Skip to content
Snippets Groups Projects
Commit 17b493a3 authored by Adam G-H's avatar Adam G-H
Browse files

Get the rename right

parent a9d06cde
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,6 @@ package_manager.settings: ...@@ -2,6 +2,6 @@ package_manager.settings:
type: config_object type: config_object
label: 'Package Manager settings' label: 'Package Manager settings'
mapping: mapping:
file_copier: file_syncer:
type: string type: string
label: 'Which file copier to use, or NULL to auto-detect' label: 'Which file syncer to use, or NULL to auto-detect'
...@@ -9,12 +9,12 @@ use PhpTuf\ComposerStager\Infrastructure\FileSyncer\FileSyncerInterface; ...@@ -9,12 +9,12 @@ use PhpTuf\ComposerStager\Infrastructure\FileSyncer\FileSyncerInterface;
use Symfony\Component\Process\ExecutableFinder; use Symfony\Component\Process\ExecutableFinder;
/** /**
* A file syncer factory which returns file copiers according to configuration. * A file syncer factory which returns file syncers according to configuration.
*/ */
class FileSyncerFactory implements FileSyncerFactoryInterface { class FileSyncerFactory implements FileSyncerFactoryInterface {
/** /**
* The decorated file copier factory. * The decorated file syncer factory.
* *
* @var \PhpTuf\ComposerStager\Infrastructure\FileSyncer\FileSyncerFactoryInterface * @var \PhpTuf\ComposerStager\Infrastructure\FileSyncer\FileSyncerFactoryInterface
*/ */
...@@ -46,17 +46,17 @@ class FileSyncerFactory implements FileSyncerFactoryInterface { ...@@ -46,17 +46,17 @@ class FileSyncerFactory implements FileSyncerFactoryInterface {
* *
* @param \Symfony\Component\Process\ExecutableFinder $executable_finder * @param \Symfony\Component\Process\ExecutableFinder $executable_finder
* The Symfony executable finder. * The Symfony executable finder.
* @param \PhpTuf\ComposerStager\Infrastructure\FileSyncer\FileSyncerInterface $php_file_copier * @param \PhpTuf\ComposerStager\Infrastructure\FileSyncer\FileSyncerInterface $php_file_syncer
* The PHP file syncer service. * The PHP file syncer service.
* @param \PhpTuf\ComposerStager\Infrastructure\FileSyncer\FileSyncerInterface $rsync_file_copier * @param \PhpTuf\ComposerStager\Infrastructure\FileSyncer\FileSyncerInterface $rsync_file_syncer
* The rsync file syncer service. * The rsync file syncer service.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory service. * The config factory service.
*/ */
public function __construct(ExecutableFinder $executable_finder, FileSyncerInterface $php_file_copier, FileSyncerInterface $rsync_file_copier, ConfigFactoryInterface $config_factory) { public function __construct(ExecutableFinder $executable_finder, FileSyncerInterface $php_file_syncer, FileSyncerInterface $rsync_file_syncer, ConfigFactoryInterface $config_factory) {
$this->decorated = new StagerFileSyncerFactory($executable_finder, $php_file_copier, $rsync_file_copier); $this->decorated = new StagerFileSyncerFactory($executable_finder, $php_file_syncer, $rsync_file_syncer);
$this->phpFileSyncer = $php_file_copier; $this->phpFileSyncer = $php_file_syncer;
$this->rsyncFileSyncer = $rsync_file_copier; $this->rsyncFileSyncer = $rsync_file_syncer;
$this->configFactory = $config_factory; $this->configFactory = $config_factory;
} }
...@@ -64,10 +64,10 @@ class FileSyncerFactory implements FileSyncerFactoryInterface { ...@@ -64,10 +64,10 @@ class FileSyncerFactory implements FileSyncerFactoryInterface {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function create(): FileSyncerInterface { public function create(): FileSyncerInterface {
$copier = $this->configFactory->get('package_manager.settings') $syncer = $this->configFactory->get('package_manager.settings')
->get('file_copier'); ->get('file_syncer');
switch ($copier) { switch ($syncer) {
case 'rsync': case 'rsync':
return $this->rsyncFileSyncer; return $this->rsyncFileSyncer;
......
...@@ -31,36 +31,36 @@ class FileCopierFactoryTest extends KernelTestBase { ...@@ -31,36 +31,36 @@ class FileCopierFactoryTest extends KernelTestBase {
} }
/** /**
* Tests creating a file copier using our specialized factory class. * Tests creating a file syncer using our specialized factory class.
* *
* @param string|null $configured_copier * @param string|null $configured_syncer
* The copier to use, as configured in automatic_updates.settings. Can be * The syncer to use, as configured in automatic_updates.settings. Can be
* 'rsync', 'php', or NULL. * 'rsync', 'php', or NULL.
* *
* @dataProvider providerFactory * @dataProvider providerFactory
*/ */
public function testFactory(?string $configured_copier): void { public function testFactory(?string $configured_syncer): void {
$factory = $this->container->get('package_manager.file_copier.factory'); $factory = $this->container->get('package_manager.file_syncer.factory');
switch ($configured_copier) { switch ($configured_syncer) {
case 'rsync': case 'rsync':
$expected_copier = $this->container->get('package_manager.file_copier.rsync'); $expected_syncer = $this->container->get('package_manager.file_syncer.rsync');
break; break;
case 'php': case 'php':
$expected_copier = $this->container->get('package_manager.file_copier.php'); $expected_syncer = $this->container->get('package_manager.file_syncer.php');
break; break;
default: default:
$expected_copier = $factory->create(); $expected_syncer = $factory->create();
break; break;
} }
$this->config('package_manager.settings') $this->config('package_manager.settings')
->set('file_copier', $configured_copier) ->set('file_syncer', $configured_syncer)
->save(); ->save();
$this->assertSame($expected_copier, $factory->create()); $this->assertSame($expected_syncer, $factory->create());
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment