-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
225 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
if !exists('g:test#php#codeception#file_pattern') | ||
let g:test#php#codeception#file_pattern = | ||
\ '\v((c|C)e(p|s)t\.php$|\.feature$|(t|T)est\.php$)' | ||
endif | ||
|
||
function! test#php#codeception#test_file(file) abort | ||
if a:file =~# g:test#php#codeception#file_pattern | ||
return filereadable('./codeception.yml') | ||
endif | ||
endfunction | ||
|
||
function! test#php#codeception#build_position(type, position) abort | ||
if a:type == 'nearest' | ||
let testname = s:nearest_test(a:position) | ||
let filename = a:position['file'] | ||
if !empty(testname) | let filename .= ':' . testname | endif | ||
return [filename] | ||
elseif a:type == 'file' | ||
return [a:position['file']] | ||
else | ||
return [] | ||
endif | ||
endfunction | ||
|
||
function! test#php#codeception#build_args(args) abort | ||
let args = a:args | ||
|
||
if test#base#no_colors() | ||
let args = ['--no-ansi'] + args | ||
endif | ||
|
||
return ['run'] + args | ||
endfunction | ||
|
||
function! test#php#codeception#executable() abort | ||
if filereadable('./vendor/bin/codecept') | ||
return './vendor/bin/codecept' | ||
elseif filereadable('./bin/codecept') | ||
return './bin/codecept' | ||
else | ||
return 'codecept' | ||
endif | ||
endfunction | ||
|
||
function! s:nearest_test(position) | ||
let name = test#base#nearest_test(a:position, g:test#php#patterns) | ||
return join(name['test']) | ||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
source spec/support/helpers.vim | ||
|
||
describe "Codeception" | ||
|
||
before | ||
cd spec/fixtures/codeception | ||
end | ||
|
||
after | ||
call Teardown() | ||
cd - | ||
end | ||
|
||
it "runs cest file tests" | ||
view tests/functional/NormalCest.php | ||
TestFile | ||
|
||
Expect g:test#last_command == 'codecept run tests/functional/NormalCest.php' | ||
end | ||
|
||
it "runs cept file tests" | ||
view tests/functional/NormalCept.php | ||
TestFile | ||
|
||
Expect g:test#last_command == 'codecept run tests/functional/NormalCept.php' | ||
end | ||
|
||
it "runs feature file tests" | ||
view tests/functional/Normal.feature | ||
TestFile | ||
|
||
Expect g:test#last_command == 'codecept run tests/functional/Normal.feature' | ||
end | ||
|
||
it "runs unit test file" | ||
view tests/functional/NormalTest.php | ||
TestFile | ||
|
||
Expect g:test#last_command == 'codecept run tests/functional/NormalTest.php' | ||
end | ||
|
||
it "runs cest nearest tests" | ||
view +21 tests/functional/NormalCest.php | ||
TestNearest | ||
|
||
Expect g:test#last_command == | ||
\ 'codecept run tests/functional/NormalCest.php:tryToTestSomethingElse' | ||
end | ||
|
||
it "runs cept nearest tests" | ||
view +3 tests/functional/NormalCept.php | ||
TestNearest | ||
|
||
Expect g:test#last_command == 'codecept run tests/functional/NormalCept.php' | ||
end | ||
|
||
it "runs feature nearest tests" | ||
view +1 tests/functional/Normal.feature | ||
TestNearest | ||
|
||
Expect g:test#last_command == 'codecept run tests/functional/Normal.feature' | ||
end | ||
|
||
it "runs nearest unit tests" | ||
view +23 tests/functional/NormalTest.php | ||
TestNearest | ||
|
||
Expect g:test#last_command == | ||
\ 'codecept run tests/functional/NormalTest.php:testMe' | ||
end | ||
|
||
it "runs test suites" | ||
view tests/functional/NormalCest.php | ||
TestSuite | ||
|
||
Expect g:test#last_command == 'codecept run' | ||
end | ||
|
||
it "doesn't recognize files that don't end with 'Cest', 'Cept' or 'Test'" | ||
view tests/functional/normal.php | ||
TestFile | ||
|
||
Expect exists('g:test#last_command') == 0 | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
actor: Tester | ||
paths: | ||
tests: tests | ||
log: tests/_output | ||
data: tests/_data | ||
support: tests/_support | ||
envs: tests/_envs | ||
settings: | ||
bootstrap: _bootstrap.php | ||
colors: true | ||
memory_limit: 1024M | ||
extensions: | ||
enabled: | ||
- Codeception\Extension\RunFailed | ||
modules: | ||
config: | ||
Db: | ||
dsn: '' | ||
user: '' | ||
password: '' | ||
dump: tests/_data/dump.sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Feature: Normal | ||
In order to ... | ||
As a ... | ||
I need to ... | ||
|
||
Scenario: try Normal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
$I = new FunctionalTester($scenario); | ||
$I->wantTo('perform actions and see result'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
|
||
class NormalCest | ||
{ | ||
public function _before(FunctionalTester $I) | ||
{ | ||
} | ||
|
||
public function _after(FunctionalTester $I) | ||
{ | ||
} | ||
|
||
// tests | ||
public function tryToTest(FunctionalTester $I) | ||
{ | ||
$I->wantTo('perform actions and see result'); | ||
} | ||
|
||
public function tryToTestSomethingElse(FunctionalTester $I) | ||
{ | ||
$I->wantTo('perform another actions and see result'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
|
||
class NormalTest extends \Codeception\Test\Unit | ||
{ | ||
/** | ||
* @var \FunctionalTester | ||
*/ | ||
protected $tester; | ||
|
||
protected function _before() | ||
{ | ||
} | ||
|
||
protected function _after() | ||
{ | ||
} | ||
|
||
// tests | ||
public function testMe() | ||
{ | ||
|
||
} | ||
|
||
public function testSomethingElse() | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
// Here you can initialize variables that will be available to your tests |