-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit c93dc8a
Showing
7 changed files
with
158 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
language: php | ||
|
||
php: | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
|
||
before_script: | ||
- composer self-update | ||
- composer require vendor/package | ||
|
||
script: phpunit | ||
|
||
# fast_finish: If your build fails do not continue trying to build, just stop. | ||
matrix: | ||
fast_finish: true | ||
|
||
notifications: | ||
on_success: never | ||
on_failure: always |
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 @@ | ||
# Sample CI php project |
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,70 @@ | ||
<?php | ||
|
||
/** | ||
* Autoloader needed for phpunit only. | ||
*/ | ||
|
||
/** | ||
* An example of a project-specific implementation. | ||
* | ||
* After registering this autoload function with SPL, the following line | ||
* would cause the function to attempt to load the \Foo\Bar\Baz\Qux class | ||
* from /path/to/project/src/Baz/Qux.php: | ||
* | ||
* new \Foo\Bar\Baz\Qux; | ||
* | ||
* @param string $class The fully-qualified class name. | ||
* @return void | ||
*/ | ||
|
||
function autoload_init( $class_prefix, $base_dir ) { | ||
|
||
spl_autoload_register(function ($class) use ( $base_dir, $class_prefix ) { | ||
|
||
// does the class use the namespace prefix? | ||
$len = strlen($class_prefix); | ||
|
||
if (strncmp($class_prefix, $class, $len) !== 0) { | ||
// no, move to the next registered autoloader | ||
return; | ||
} | ||
|
||
// get the relative class name | ||
$relative_class = substr($class, $len); | ||
|
||
// replace the namespace prefix with the base directory, replace namespace | ||
// separators with directory separators in the relative class name, append | ||
// with .php | ||
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; | ||
|
||
// if the file exists, require it | ||
if (file_exists($file)) { | ||
require $file; | ||
} | ||
}); | ||
|
||
} | ||
|
||
autoload_init( 'myvendor\\mymodule', __DIR__ . '/src/' ); | ||
|
||
// during Travis CI build for example, if any composer dependencies are required, | ||
// a "vendor" folder will be created during testing inside of your root project. | ||
// we require the composer autoloader here. | ||
if ( is_dir( __DIR__ . '/vendor') && file_exists( __DIR__ . '/vendor/autoload.php') ) { | ||
require_once __DIR__ . '/vendor/autoload.php'; | ||
} | ||
|
||
// assuming that you are a vendor, and that you use other sub-packages created | ||
// by you, they are located within a level up folder of your project | ||
foreach ( $dependencies = [ | ||
'mysubmodule1', | ||
'mysubmodule2' | ||
] as $submodule ) { | ||
|
||
if ( is_dir( __DIR__ . '/../' . $submodule ) && is_dir( __DIR__ . '/../src' ) ) { | ||
autoload_init( 'myvendor\\' . $submodule, __DIR__ . '/../' . $submodule . '/src'); | ||
} | ||
|
||
} | ||
|
||
unset( $dependencies ); |
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 @@ | ||
{ | ||
"name": "myvendor/mypackage", | ||
"description": "A library that is doing ...", | ||
"type": "library", | ||
"license": "MIT", | ||
"homepage": "https://www.example.com", | ||
"keywords": [ | ||
"example", | ||
"keywords" | ||
], | ||
"authors": [ { | ||
"name": "your name", | ||
"email": "email@example.com", | ||
"homepage": "http://www.example.com/" | ||
} ], | ||
|
||
"require": { | ||
"php": ">=5.4", | ||
"vendor/package": "0.*" | ||
}, | ||
|
||
"autoload": { | ||
"psr-4": { | ||
"myvendor\\mypackage": "src/" | ||
} | ||
}, | ||
|
||
"minimum-stability": "dev" | ||
} |
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,7 @@ | ||
<phpunit bootstrap="bootstrap.php"> | ||
<testsuites> | ||
<testsuite name="tests"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
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,11 @@ | ||
<?php | ||
|
||
namespace myvendorname\mymodulename; | ||
|
||
/** | ||
* This class is doing ... | ||
*/ | ||
|
||
class Dummy { | ||
|
||
} |
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,20 @@ | ||
<?php | ||
|
||
|
||
class SampleTest extends PHPUnit_Framework_TestCase { | ||
|
||
public function argumentsProvider() { | ||
return [ | ||
[ false, 1, 3 ], | ||
[ true, 2, 2 ] | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider argumentsProvider | ||
*/ | ||
public function testAssertion( $expectedValue, $number1, $number2 ) { | ||
$this->assertEquals( $expectedValue, $number1 === $number2 ); | ||
} | ||
|
||
} |