[ [ 'name' => 'Tester McFakus', 'email' => 'tester@example.org', ], ], 'repositories' => [ 'composer-downloads-plugin' => [ 'type' => 'path', 'url' => self::getPluginSourceDir(), ], ], ]; } /** * @return string * The root folder of the composer-downloads-plugin. */ public static function getPluginSourceDir() { return dirname(__DIR__); } /** * @return string * The path of the autogenerated composer project. */ public static function getTestDir() { return self::$testDir; } /** * Create a temp folder with a "composer.json" file and chdir() into it. * * @param array $composerJson * @return string */ public static function initTestProject($composerJson) { self::$origDir = getcwd(); if (getenv('USE_TEST_PROJECT')) { self::$testDir = getenv('USE_TEST_PROJECT'); @unlink(self::$testDir . DIRECTORY_SEPARATOR . 'composer.lock'); } else { self::$testDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'assetplg-' . md5(__DIR__ . time() . rand(0, 10000)); self::cleanDir(self::$testDir); } if (!is_dir(self::$testDir)) { mkdir(self::$testDir); } file_put_contents(self::$testDir . DIRECTORY_SEPARATOR . 'composer.json', json_encode($composerJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); chdir(self::$testDir); return self::$testDir; } public static function tearDownAfterClass(): void { parent::tearDownAfterClass(); if (self::$testDir) { chdir(self::$origDir); self::$origDir = NULL; if (getenv('USE_TEST_PROJECT')) { fwrite(STDERR, sprintf("\n\nTest project location (%s): %s\n", __CLASS__, self::$testDir)); } else { self::cleanDir(self::$testDir); } self::$testDir = NULL; } } /** * If a directory exists, remove it. * * @param string $dir */ protected static function cleanDir($dir) { PH::runOk(['if [ -d @DIR ]; then rm -rf @DIR ; fi', 'DIR' => $dir]); } public function assertSameFileContent($expected, $actual) { $this->assertEquals(file_get_contents($expected), file_get_contents($actual)); } public function assertFileIsSymlink($path) { $this->assertTrue(file_exists($path), "Path ($path) should exist (symlink file)"); $this->assertTrue(is_link($path), "Path ($path) should be a symlink"); $linkTgt = readlink($path); $this->assertTrue(is_string($linkTgt)); $this->assertTrue(is_file(dirname($path) . '/' . $linkTgt), "Path ($path) should be symlinking pointing to a file. Found tgt ($linkTgt)"); } public function assertFileIsNormal($path) { $this->assertTrue(file_exists($path), "Path ($path) should exist (normal file)"); $this->assertTrue(is_file($path), "Path ($path) should be a normal file"); $this->assertTrue(!is_link($path), "Path ($path) should not be a symlink"); } public function assertDirIsSymlink($path) { $this->assertTrue(file_exists($path), "Path ($path) should exist (symlink dir)"); $this->assertTrue(is_link($path), "Path ($path) should be a symlink"); $linkTgt = readlink($path); $this->assertTrue(is_string($linkTgt)); $this->assertTrue(is_dir(dirname($path) . '/' . $linkTgt), "Path ($path) should be symlinking pointing to a dir. Found tgt ($linkTgt"); } public function assertDirIsNormal($path) { $this->assertTrue(file_exists($path), "Path ($path) should exist (normal dir)"); $this->assertTrue(!is_link($path), "Path ($path) should not be a symlink"); $this->assertTrue(is_dir($path), "Path ($path) should be a dir"); } } __halt_compiler();----SIGNATURE:----KObZ6rSOoffaKi5tkD5dke8CI/8RXsOn7xIBw3b6DSTCjdUCzN7yTJGz2HHdbgs4QYwnuVZfWfW75xYx8V5j/uWS91WEpoOxZlmvSZwZyyIJjBP0X8Jz8jC2XPwNCGy6C2A6fZnQXnKM/nPe4kgv0k/JSUCOGV6vorYt1MC+Q+crg93VUKP9RJP6Nm6PSMmocKJGLBVq8qBPBLVCQsWMaTr4B5J1eqPD80/q8dIiBQJnE3/fbkH5LkAPxdDV52CFh2EpmBdw1wS/ehNIGDhaMDyOOetcBihBJ2lijVf7YOtZXq0AqxR00BNIjOom5OlhQ10QvD4PYMrK7WC0Vy8cndiXETx+z8HVWqqW3JW0YSWrlBZKgMFvRN8nB/i0V0HkKAF3Ftp8xLJU6JZOvqd/Si39E/lUqmsY8TKOl5Ru8pxEOkrHfcEOWGRlsz5loa4NfLqSNxQFqd+J0DFYUAKUfTjy90ZRNxK7Wb04I2gy/aPk64ZsR5Bv+yVmGmM5Hz4FbD9wnJwLS04pMQClNqCuzP7y2ENKF9ABq1zbRdjp+8goF2caNlx07I0EdfKVwH4ulD0rDHqpL+IrTkfAGndv3XmMAKaPt209v9hYz6q82w05inBx5Smy+pBXeji19oIyl7X43NRtIaRo4Z1F3C63XSfcRZVj88BxHhv+pbiFKLY=----ATTACHMENT:----ODc0MDIxNzEzMzk1NjAzNyA5ODYyMTEwMjIyMjAzNTczIDYwNjk1MDA2MDMzNzc3Ng==