Skip to content

Commit

Permalink
Merge pull request #3 from browserfs/develop
Browse files Browse the repository at this point in the history
CI support
  • Loading branch information
sfia-andreidaniel committed Jan 22, 2016
2 parents 6971b3c + d3a74e8 commit 37991f9
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 8 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 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

0 comments on commit 37991f9

Please sign in to comment.