示例#1
0
 public function testIfWeGetTheLastCue()
 {
     $filename = __DIR__ . '/../../Fixtures/Json/en.json';
     $file = new JsonFile($filename);
     $expectedCue = new JsonCue(1396000, 1397000, "Thanks.");
     $expectedCue->setStartOfParagraph(true);
     $this->assertEquals($expectedCue, $file->getLastCue());
 }
示例#2
0
 protected function format($data)
 {
     if (is_array($data)) {
         reset($data);
         if (is_numeric(key($data))) {
             return '[' . implode(', ', $data) . ']';
         }
         $out = '{' . $this->newline;
         foreach ($data as $key => $val) {
             $elems[] = $this->indent . $this->indent . JsonFile::encode($key) . ': ' . $this->format($val);
         }
         return $out . implode(',' . $this->newline, $elems) . $this->newline . $this->indent . '}';
     }
     return JsonFile::encode($data);
 }
 public function format($data, $depth = 0)
 {
     if (is_array($data)) {
         reset($data);
         if (is_numeric(key($data))) {
             foreach ($data as $key => $val) {
                 $data[$key] = $this->format($val, $depth + 1);
             }
             return '[' . implode(', ', $data) . ']';
         }
         $out = '{' . $this->newline;
         $elems = array();
         foreach ($data as $key => $val) {
             $elems[] = str_repeat($this->indent, $depth + 2) . JsonFile::encode($key) . ': ' . $this->format($val, $depth + 1);
         }
         return $out . implode(',' . $this->newline, $elems) . $this->newline . str_repeat($this->indent, $depth + 1) . '}';
     }
     return JsonFile::encode($data);
 }
示例#4
0
  /**
   * {@inheritdoc}
   */
  public function rebuildRootPackage() {
    $root_package = JsonFile::read($this->root . '/composer.json');
    // Rebuild the merged keys.
    $merged_extension_package = $this->buildMergedExtensionPackage();
    $root_package['require'] = [
      'composer/installers' => '^1.0.21',
      'wikimedia/composer-merge-plugin' => '^1.3.0',
    ] + $merged_extension_package['require'];
    $root_package['require-dev'] = $merged_extension_package['require-dev'];
    $root_package['replace'] = [
      'drupal/core' => '~8.0',
    ] + $merged_extension_package['replace'];
    $root_package['repositories'] = $merged_extension_package['repositories'];
    // Ensure the presence of the Drupal Packagist repository.
    // @todo Remove once Drupal Packagist moves to d.o and gets added to
    // the root package by default.
    $root_package['repositories'][] = [
      'type' => 'composer',
      'url' => 'https://packagist.drupal-composer.org',
    ];

    JsonFile::write($this->root . '/composer.json', $root_package);
  }
示例#5
0
 /**
  * {@inheritdoc}
  */
 public function rebuildRootPackage()
 {
     // See the getCorePackage() interface docblock for an explanation of why
     // we're writing the root package to core/composer.json.
     $core_package = $this->getCorePackage();
     $extension_packages = $this->getExtensionPackages();
     $root_package = $this->rootPackageBuilder->build($core_package, $extension_packages);
     JsonFile::write($this->root . '/core/composer.json', $root_package);
 }
  /**
   * {@inheritdoc}
   */
  public function rebuildRootPackage() {
    $root_package = JsonFile::read($this->root . '/composer.json');
    // Initialize known start values. These should match what's already in
    // the root composer.json shipped with Drupal.
    $core_requirement = $root_package['replace']['drupal/core'];
    $root_package['replace'] = [
      'drupal/core' => $core_requirement,
    ];
    $root_package['repositories'] = [];
    $root_package['extra']['merge-plugin']['include'] = [
      'core/composer.json',
    ];
    // Add the discovered extensions to the replace list so that they doesn't
    // get redownloaded if required by another package.
    foreach ($this->getExtensionPackages() as $extension_package) {
      $version = '8.*';
      if (isset($extension_package['extra']['branch-alias']['dev-master'])) {
        $version = $extension_package['extra']['branch-alias']['dev-master'];
      }
      $root_package['replace'][$extension_package['name']] = $version;
    }
    // Ensure the presence of the Drupal Packagist repository.
    // @todo Remove once Drupal Packagist moves to d.o and gets added to
    // the root package by default.
    $root_package['repositories'][] = [
      'type' => 'composer',
      'url' => 'https://packagist.drupal-composer.org',
    ];
    // Add each discovered extension to the merge list.
    foreach ($this->getExtensionPackages() as $extension_package) {
      $root_package['extra']['merge-plugin']['include'][] = $extension_package['extra']['path'];
    }

    JsonFile::write($this->root . '/composer.json', $root_package);
  }
示例#7
0
 /**
  * @covers rvilbrandt\gamebook\Loader\Json::load
  * @expectedException rvilbrandt\gamebook\Loader\InvalidFormatException
  */
 public function testLoadInvalidFormat()
 {
     $this->object->setFilePath(__DIR__ . "/../../data/gamebook_invalid_format.json");
     $this->object->load();
 }