Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI support #3

Merged
merged 8 commits into from
Jan 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 browserfs/string

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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Runtime Types
A PHP library used to test at runtime if a value matches a pattern ( or a type ).

[![Build Status](https://travis-ci.org/browserfs/runtime.svg?branch=master)](https://travis-ci.org/browserfs/runtime)

## Why?
How many times, and how many lines of code you had to write in order
to check the type of data and the values in data provided from webservices,
Expand Down Expand Up @@ -134,3 +136,8 @@ validator WebserviceResponse {
}
?>
```

In the above example, we tested if the $result variable is validatable by the
validator called "WebserviceResponse". If any errors are encountered by the
validator, in optional argument $errors, the testing system is storing all
the errors occured.
13 changes: 11 additions & 2 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,14 @@ function autoload_init( $class_prefix, $base_dir ) {

}

autoload_init( 'browserfs\\string', __DIR__ . '/../string/src/' );
autoload_init( 'browserfs\\', __DIR__ . '/src/' );
autoload_init( 'browserfs\\', __DIR__ . '/src/' );

// throw new \Exception( json_encode( scandir( __DIR__ ), JSON_PRETTY_PRINT ) );

if ( is_dir( __DIR__ . '/vendor') && file_exists( __DIR__ . '/vendor/autoload.php') ) {
require_once __DIR__ . '/vendor/autoload.php';
} else {
if ( is_dir( __DIR__ . '/../string' ) ) {
autoload_init( 'browserfs\\string', __DIR__ . '/../string/src');
}
}
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="runtime">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 1 addition & 1 deletion src/runtime/Type/Any.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class Any extends \browserfs\runtime\Type {

public function test( $mixed ) {
public function test( $mixed, &$errors = null ) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/Type/Boolean.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class Boolean extends \browserfs\runtime\Type {

public function test( $mixed ) {
public function test( $mixed, &$errors = null ) {
return $mixed === true || $mixed === false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/Type/Float.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class Float extends \browserfs\runtime\Type {

public function test( $mixed ) {
public function test( $mixed, &$errors = null ) {
return is_float( $mixed );
}

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/Type/Int.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class Int extends \browserfs\runtime\Type {

public function test( $mixed ) {
public function test( $mixed, &$errors = null ) {
return is_int( $mixed );
}

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/Type/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class Number extends \browserfs\runtime\Type {

public function test( $mixed ) {
public function test( $mixed, &$errors = null ) {
return is_int( $mixed ) || is_float( $mixed );
}

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/Type/String.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class String extends \browserfs\runtime\Type {

public function test( $mixed ) {
public function test( $mixed, &$errors = null ) {
return is_string( $mixed );
}

Expand Down