forked from cakephp/codeception
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstaller.php
More file actions
41 lines (36 loc) · 1.1 KB
/
Copy pathInstaller.php
File metadata and controls
41 lines (36 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace Cake\Codeception\Console;
use Composer\Script\Event;
class Installer
{
/**
* Overwrites the `codecept` binary to use `Cake\Codeception` classes
* where necessary.
*
* @param \Composer\Script\Event $event Event.
*/
public static function customizeCodeceptionBinary(Event $event)
{
$binDir = dirname(dirname(dirname(dirname(__DIR__)))) . DIRECTORY_SEPARATOR;
$binDir = $binDir . 'codeception' . DIRECTORY_SEPARATOR . 'codeception';
$binFile = $binDir . DIRECTORY_SEPARATOR . 'codecept';
$contents = file_get_contents($binFile);
$from = 'new Codeception\\Command\\';
$to = 'new Cake\\Codeception\\Command\\';
$needles = [
'Build',
'Bootstrap',
'GenerateCest',
'GenerateGroup',
'GenerateSuite',
];
foreach ($needles as $needle) {
$contents = str_replace(
$from . $needle,
$to . $needle,
$contents
);
}
file_put_contents($binFile, $contents);
}
}