Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / drupal-composer / drupal-scaffold / tests / PluginTest.php
index 2a0f3f904f5e2aabb22b059b842f1e6d3a6099fa..a392e060d9556a8500275877ce878c5d9c095c00 100644 (file)
@@ -1,18 +1,14 @@
 <?php
 
-/**
- * @file
- * Contains \DrupalComposer\DrupalScaffold\Tests\PluginTest.
- */
-
 namespace DrupalComposer\DrupalScaffold\Tests;
 
 use Composer\Util\Filesystem;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Tests composer plugin functionality.
  */
-class PluginTest extends \PHPUnit_Framework_TestCase {
+class PluginTest extends TestCase {
 
   /**
    * @var \Composer\Util\Filesystem
@@ -35,7 +31,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
   protected $tmpReleaseTag;
 
   /**
-   * SetUp test
+   * SetUp test.
    */
   public function setUp() {
     $this->rootDir = realpath(realpath(__DIR__ . '/..'));
@@ -52,12 +48,11 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
   }
 
   /**
-   * tearDown
+   * TearDown.
    *
    * @return void
    */
-  public function tearDown()
-  {
+  public function tearDown() {
     $this->fs->removeDirectory($this->tmpDir);
     $this->git(sprintf('tag -d "%s"', $this->tmpReleaseTag));
   }
@@ -73,16 +68,16 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
     $this->assertFileExists($exampleScaffoldFile, 'Scaffold file should be automatically installed.');
     $this->fs->remove($exampleScaffoldFile);
     $this->assertFileNotExists($exampleScaffoldFile, 'Scaffold file should not be exist.');
-    $this->composer('drupal-scaffold');
-    $this->assertFileExists($exampleScaffoldFile, 'Scaffold file should be installed by "drupal-scaffold" command.');
+    $this->composer('drupal:scaffold');
+    $this->assertFileExists($exampleScaffoldFile, 'Scaffold file should be installed by "drupal:scaffold" command.');
 
     foreach (['8.0.1', '8.1.x-dev', '8.3.0', '8.5.x-dev'] as $version) {
       // We touch a scaffold file, so we can check the file was modified after
       // the scaffold update.
       touch($exampleScaffoldFile);
       $mtime_touched = filemtime($exampleScaffoldFile);
-      // Requiring a newer version triggers "composer update"
-      $this->composer('require --update-with-dependencies --prefer-dist --update-no-dev drupal/core:"' . $version .'"');
+      // Requiring a newer version triggers "composer update".
+      $this->composer('require --update-with-dependencies --prefer-dist --update-no-dev drupal/core:"' . $version . '"');
       clearstatcache();
       $mtime_after = filemtime($exampleScaffoldFile);
       $this->assertNotEquals($mtime_after, $mtime_touched, 'Scaffold file was modified by composer update. (' . $version . ')');
@@ -93,12 +88,14 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
           $this->assertFileNotExists($this->tmpDir . DIRECTORY_SEPARATOR . '.eslintrc.json');
           $this->assertFileNotExists($this->tmpDir . DIRECTORY_SEPARATOR . '.ht.router.php');
           break;
+
         case '8.3.0':
           // Note we don't clean up .eslintrc file.
           $this->assertFileExists($this->tmpDir . DIRECTORY_SEPARATOR . '.eslintrc');
           $this->assertFileExists($this->tmpDir . DIRECTORY_SEPARATOR . '.eslintrc.json');
           $this->assertFileNotExists($this->tmpDir . DIRECTORY_SEPARATOR . '.ht.router.php');
           break;
+
         case '8.5.x-dev':
           $this->assertFileExists($this->tmpDir . DIRECTORY_SEPARATOR . '.eslintrc');
           $this->assertFileExists($this->tmpDir . DIRECTORY_SEPARATOR . '.eslintrc.json');
@@ -107,15 +104,11 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
       }
     }
 
-    // We touch a scaffold file, so we can check the file was modified after
-    // the custom commandscaffold update.
-    touch($exampleScaffoldFile);
-    clearstatcache();
-    $mtime_touched = filemtime($exampleScaffoldFile);
-    $this->composer('drupal-scaffold');
-    clearstatcache();
-    $mtime_after = filemtime($exampleScaffoldFile);
-    $this->assertNotEquals($mtime_after, $mtime_touched, 'Scaffold file was modified by custom command.');
+    // We touch a scaffold file, so we can check the file was modified by the
+    // custom command.
+    file_put_contents($exampleScaffoldFile, 1);
+    $this->composer('drupal:scaffold');
+    $this->assertNotEquals(file_get_contents($exampleScaffoldFile), 1, 'Scaffold file was modified by custom command.');
   }
 
   /**
@@ -148,16 +141,13 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
         array(
           'type' => 'vcs',
           'url' => $this->rootDir,
-        )
+        ),
       ),
       'require' => array(
         'drupal-composer/drupal-scaffold' => $this->tmpReleaseTag,
         'composer/installers' => '^1.0.20',
         'drupal/core' => '8.0.0',
       ),
-      'scripts' => array(
-        'drupal-scaffold' =>  'DrupalComposer\\DrupalScaffold\\Plugin::scaffold'
-      ),
       'minimum-stability' => 'dev',
     );
   }
@@ -166,7 +156,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
    * Wrapper for the composer command.
    *
    * @param string $command
-   *   Composer command name, arguments and/or options
+   *   Composer command name, arguments and/or options.
    */
   protected function composer($command) {
     chdir($this->tmpDir);
@@ -199,6 +189,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
     if (is_dir($directory)) {
       $this->fs->removeDirectory($directory);
     }
-    mkdir($directory, 0777, true);
+    mkdir($directory, 0777, TRUE);
   }
+
 }