class RsyncValidatorTest
@covers \Drupal\package_manager\Validator\RsyncValidator @group package_manager @internal
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait
- class \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase extends \Drupal\KernelTests\KernelTestBase uses \Drupal\Tests\package_manager\Traits\AssertPreconditionsTrait, \Drupal\Tests\package_manager\Traits\ComposerStagerTestTrait, \Drupal\Tests\package_manager\Traits\FixtureManipulatorTrait, \Drupal\Tests\package_manager\Traits\FixtureUtilityTrait, \Drupal\package_manager\StatusCheckTrait, \Drupal\Tests\package_manager\Traits\ValidationTestTrait
- class \Drupal\Tests\package_manager\Kernel\RsyncValidatorTest extends \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase
- class \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase extends \Drupal\KernelTests\KernelTestBase uses \Drupal\Tests\package_manager\Traits\AssertPreconditionsTrait, \Drupal\Tests\package_manager\Traits\ComposerStagerTestTrait, \Drupal\Tests\package_manager\Traits\FixtureManipulatorTrait, \Drupal\Tests\package_manager\Traits\FixtureUtilityTrait, \Drupal\package_manager\StatusCheckTrait, \Drupal\Tests\package_manager\Traits\ValidationTestTrait
Expanded class hierarchy of RsyncValidatorTest
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ RsyncValidatorTest.php, line 21
Namespace
Drupal\Tests\package_manager\KernelView source
class RsyncValidatorTest extends PackageManagerKernelTestBase {
/**
* The mocked executable finder.
*
* @var \PhpTuf\ComposerStager\API\Finder\Service\ExecutableFinderInterface
*/
private $executableFinder;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
// Set up a mocked executable finder which will always be re-injected into
// the validator when the container is rebuilt.
$this->executableFinder = $this->prophesize(ExecutableFinderInterface::class);
$this->executableFinder
->find('rsync')
->willReturn('/path/to/rsync');
parent::setUp();
}
/**
* {@inheritdoc}
*/
public function register(ContainerBuilder $container) : void {
parent::register($container);
$container->set('mock_executable_finder', $this->executableFinder
->reveal());
$container->getDefinition(RsyncValidator::class)
->setArgument('$executableFinder', new Reference('mock_executable_finder'));
}
/**
* Tests that the stage cannot be created if rsync is selected, but not found.
*/
public function testPreCreateFailsIfRsyncNotFound() : void {
/** @var \PhpTuf\ComposerStager\API\Translation\Factory\TranslatableFactoryInterface $translatable_factory */
$translatable_factory = $this->container
->get(TranslatableFactoryInterface::class);
$message = $translatable_factory->createTranslatableMessage('Nope!');
$this->executableFinder
->find('rsync')
->willThrow(new LogicException($message));
$result = ValidationResult::createError([
t('<code>rsync</code> is not available.'),
]);
$this->assertResults([
$result,
], PreCreateEvent::class);
$this->enableModules([
'help',
]);
$result = ValidationResult::createError([
t('<code>rsync</code> is not available. See the <a href="/admin/help/package_manager#package-manager-faq-rsync">Package Manager help</a> for more information on how to resolve this.'),
]);
$this->assertResults([
$result,
], PreCreateEvent::class);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.