-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCloneCest.php
More file actions
83 lines (60 loc) · 2.85 KB
/
CloneCest.php
File metadata and controls
83 lines (60 loc) · 2.85 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
namespace StellarWP\Pup\Tests\Cli\Commands;
use StellarWP\Pup\Tests\Cli\AbstractBase;
use StellarWP\Pup\Tests\CliTester;
class CloneCest extends AbstractBase {
/**
* @test
*/
public function it_should_clone_the_default_branch_of_a_git_repo( CliTester $I ) {
$project_path = $this->tests_root . '/_data/fake-project-git-repo';
system( 'rm -rf ' . $project_path );
system( 'cp -r ' . $this->tests_root . '/_data/fake-project ' . $project_path );
chdir( $project_path );
system( 'cd ' . $project_path . ' && git init --quiet' );
system( 'cd ' . $project_path . ' && git add .' );
system( 'cd ' . $project_path . ' && git config user.email "fake@fake.fake"' );
system( 'cd ' . $project_path . ' && git config user.name "Fake Fake"' );
system( 'cd ' . $project_path . ' && git commit -m "Initial commit" --quiet' );
$puprc = $this->get_puprc();
$puprc['repo'] = $project_path;
$this->write_puprc( $puprc, 'fake-project-git-repo' );
$I->runShellCommand( "php {$this->pup} clone" );
$I->seeResultCodeIs( 0 );
$I->assertTrue( file_exists( '.pup-build/bootstrap.php' ) );
$output = $I->grabShellOutput();
$this->assertMatchesStringSnapshot( str_replace( $this->plugin_root, '{PUP_ROOT}', $output ) );
$I->runShellCommand( "php {$this->pup} clean" );
$this->reset_data_and_location();
system( 'rm -rf ' . $project_path );
}
/**
* @test
*/
public function it_should_clone_a_specific_branch_of_a_git_repo( CliTester $I ) {
$project_path = $this->tests_root . '/_data/fake-project-git-repo';
system( 'rm -rf ' . $project_path );
system( 'cp -r ' . $this->tests_root . '/_data/fake-project ' . $project_path );
chdir( $project_path );
system( 'cd ' . $project_path . ' && git init --quiet' );
system( 'cd ' . $project_path . ' && git add .' );
system( 'cd ' . $project_path . ' && git config user.email "fake@fake.fake"' );
system( 'cd ' . $project_path . ' && git config user.name "Fake Fake"' );
system( 'cd ' . $project_path . ' && git commit -m "Initial commit" --quiet' );
system( 'cd ' . $project_path . ' && git checkout -b other-branch --quiet' );
system( 'cd ' . $project_path . ' && touch new-file.txt' );
system( 'cd ' . $project_path . ' && git add new-file.txt' );
system( 'cd ' . $project_path . ' && git commit new-file.txt -m "Added new file" --quiet' );
$puprc = $this->get_puprc();
$puprc['repo'] = $project_path;
$this->write_puprc( $puprc, 'fake-project-git-repo' );
$I->runShellCommand( "php {$this->pup} clone --branch other-branch" );
$I->seeResultCodeIs( 0 );
$I->assertTrue( file_exists( '.pup-build/new-file.txt' ) );
$output = $I->grabShellOutput();
$this->assertMatchesStringSnapshot( str_replace( $this->plugin_root, '{PUP_ROOT}', $output ) );
$I->runShellCommand( "php {$this->pup} clean" );
$this->reset_data_and_location();
system( 'rm -rf ' . $project_path );
}
}