|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace StellarWP\Pup\Tests\Cli\Commands; |
| 4 | + |
| 5 | +use StellarWP\Pup\Tests\Cli\AbstractBase; |
| 6 | +use StellarWP\Pup\Tests\CliTester; |
| 7 | + |
| 8 | +class WorkflowCest extends AbstractBase { |
| 9 | + public function _before( CliTester $I ) { |
| 10 | + parent::_before( $I ); |
| 11 | + } |
| 12 | + |
| 13 | + /** |
| 14 | + * @test |
| 15 | + */ |
| 16 | + public function it_should_run_workflow( CliTester $I ) { |
| 17 | + $puprc = $this->get_puprc(); |
| 18 | + $puprc['workflows'] = []; |
| 19 | + $puprc['workflows']['bork'] = []; |
| 20 | + $puprc['workflows']['bork'][] = 'echo "fake project, yo"'; |
| 21 | + $this->write_puprc( $puprc ); |
| 22 | + |
| 23 | + chdir( $this->tests_root . '/_data/fake-project' ); |
| 24 | + |
| 25 | + $I->runShellCommand( "php {$this->pup} workflow bork" ); |
| 26 | + $I->seeResultCodeIs( 0 ); |
| 27 | + $I->seeInShellOutput( 'fake project, yo' ); |
| 28 | + $I->seeInShellOutput( 'Workflow complete.' ); |
| 29 | + |
| 30 | + $output = $I->grabShellOutput(); |
| 31 | + $this->assertMatchesStringSnapshot( $output ); |
| 32 | + } |
| 33 | + |
| 34 | + /** |
| 35 | + * @test |
| 36 | + */ |
| 37 | + public function it_should_run_do( CliTester $I ) { |
| 38 | + $puprc = $this->get_puprc(); |
| 39 | + $puprc['workflows'] = []; |
| 40 | + $puprc['workflows']['bork'] = []; |
| 41 | + $puprc['workflows']['bork'][] = 'echo "fake project, yo"'; |
| 42 | + $this->write_puprc( $puprc ); |
| 43 | + |
| 44 | + chdir( $this->tests_root . '/_data/fake-project' ); |
| 45 | + |
| 46 | + $I->runShellCommand( "php {$this->pup} do bork" ); |
| 47 | + $I->seeResultCodeIs( 0 ); |
| 48 | + $I->seeInShellOutput( 'fake project, yo' ); |
| 49 | + $I->seeInShellOutput( 'Workflow complete.' ); |
| 50 | + |
| 51 | + $output = $I->grabShellOutput(); |
| 52 | + $this->assertMatchesStringSnapshot( $output ); |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * @test |
| 57 | + */ |
| 58 | + public function it_should_run_build_as_workflow( CliTester $I ) { |
| 59 | + $puprc = $this->get_puprc(); |
| 60 | + $puprc['build'][] = 'echo "fake project, yo"'; |
| 61 | + $this->write_puprc( $puprc ); |
| 62 | + |
| 63 | + chdir( $this->tests_root . '/_data/fake-project' ); |
| 64 | + |
| 65 | + $I->runShellCommand( "php {$this->pup} do build" ); |
| 66 | + $I->seeResultCodeIs( 0 ); |
| 67 | + $I->seeInShellOutput( 'fake project, yo' ); |
| 68 | + $I->seeInShellOutput( 'Workflow complete.' ); |
| 69 | + |
| 70 | + $output = $I->grabShellOutput(); |
| 71 | + $this->assertMatchesStringSnapshot( $output ); |
| 72 | + } |
| 73 | + |
| 74 | + /** |
| 75 | + * @test |
| 76 | + */ |
| 77 | + public function it_should_run_build_dev_as_workflow( CliTester $I ) { |
| 78 | + $puprc = $this->get_puprc(); |
| 79 | + $puprc['build_dev'][] = 'echo "fake project, yo"'; |
| 80 | + $this->write_puprc( $puprc ); |
| 81 | + |
| 82 | + chdir( $this->tests_root . '/_data/fake-project' ); |
| 83 | + |
| 84 | + $I->runShellCommand( "php {$this->pup} do build_dev" ); |
| 85 | + $I->seeResultCodeIs( 0 ); |
| 86 | + $I->seeInShellOutput( 'fake project, yo' ); |
| 87 | + $I->seeInShellOutput( 'Workflow complete.' ); |
| 88 | + |
| 89 | + $output = $I->grabShellOutput(); |
| 90 | + $this->assertMatchesStringSnapshot( $output ); |
| 91 | + } |
| 92 | + |
| 93 | + /** |
| 94 | + * @test |
| 95 | + */ |
| 96 | + public function it_should_run_an_empty_workflow( CliTester $I ) { |
| 97 | + $puprc = $this->get_puprc(); |
| 98 | + $puprc['workflows'] = []; |
| 99 | + $puprc['workflows']['bork'] = []; |
| 100 | + $this->write_puprc( $puprc ); |
| 101 | + |
| 102 | + chdir( $this->tests_root . '/_data/fake-project' ); |
| 103 | + |
| 104 | + $I->runShellCommand( "php {$this->pup} do bork" ); |
| 105 | + $I->seeResultCodeIs( 0 ); |
| 106 | + |
| 107 | + $output = $I->grabShellOutput(); |
| 108 | + $this->assertMatchesStringSnapshot( $output ); |
| 109 | + } |
| 110 | + |
| 111 | + /** |
| 112 | + * @test |
| 113 | + */ |
| 114 | + public function it_should_fail_non_existent_workflow( CliTester $I ) { |
| 115 | + $puprc = $this->get_puprc(); |
| 116 | + $puprc['workflows'] = []; |
| 117 | + $puprc['workflows']['bork'] = []; |
| 118 | + $puprc['workflows']['bork'][] = 'echo "fake project, yo"'; |
| 119 | + $this->write_puprc( $puprc ); |
| 120 | + |
| 121 | + chdir( $this->tests_root . '/_data/fake-project' ); |
| 122 | + |
| 123 | + $I->runShellCommand( "php {$this->pup} workflow whee", false ); |
| 124 | + $I->seeResultCodeIs( 1 ); |
| 125 | + $I->seeInShellOutput( '\'whee\' does not exist.' ); |
| 126 | + |
| 127 | + $output = $I->grabShellOutput(); |
| 128 | + $this->assertMatchesStringSnapshot( $output ); |
| 129 | + } |
| 130 | +} |
0 commit comments