Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
sfia-andreidaniel committed Jan 22, 2016
0 parents commit c93dc8a
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .travis.yml
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Sample CI php project
70 changes: 70 additions & 0 deletions bootstrap.php
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 );
29 changes: 29 additions & 0 deletions composer.json
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"
}
7 changes: 7 additions & 0 deletions phpunit.xml
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>
11 changes: 11 additions & 0 deletions src/Dummy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace myvendorname\mymodulename;

/**
* This class is doing ...
*/

class Dummy {

}
20 changes: 20 additions & 0 deletions tests/SampleTest.php
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 );
}

}

0 comments on commit c93dc8a

Please sign in to comment.