Commit e0217cdb authored by Ev Maslovskiy's avatar Ev Maslovskiy Committed by Nedjo Rogers
Browse files

Issue #3306198 by Spleshka: Broken tests on 5.0.x

parent d7cbf89f
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -2,12 +2,14 @@

namespace Drupal\Tests\features\Kernel;

use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\features\Entity\FeaturesBundle;
use Drupal\features\FeaturesBundleInterface;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Archiver\ArchiveTar;
use org\bovigo\vfs\vfsStream;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;

/**
 * @group features
@@ -131,9 +133,21 @@ class FeaturesGenerateTest extends KernelTestBase {
  public function testExportWrite() {
    // Set a fake drupal root, so the testbot can also write into it.
    vfsStream::setup('drupal');
    \Drupal::getContainer()->setParameter('app.root', 'vfs://drupal');
    $this->featuresManager->setRoot('vfs://drupal');

    // We need to change the app.root in order to generate packages into
    // the virtual file system. Unfortunately, here we can't just use
    // $this->container->setParameter(), because by this time the parameter bag
    // is frozen. Also, we can't use ::register() method for this as it is
    // expected by Kernel tests, because this value gets overridden during
    // setUp() method. So we have to recreate the container instance with
    // the same values but the new app.root value.
    $container = new ContainerBuilder(new FrozenParameterBag([
        'app.root' => 'vfs://drupal',
      ] + $this->container->getParameterBag()->all()));
    $container->setDefinitions($this->container->getDefinitions());
    \Drupal::setContainer($container);

    $package = $this->featuresManager->getPackage(self::PACKAGE_NAME);
    // Find out where package will be exported.
    list($full_name, $path) = $this->featuresManager->getExportInfo($package, $this->assigner->getBundle());