-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from EvanDarwin/dev
Version 2.0.0
- Loading branch information
Showing
10 changed files
with
117 additions
and
129 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 |
---|---|---|
@@ -1,11 +1,9 @@ | ||
language: php | ||
install: composer install -o | ||
install: | ||
- wget -O phpunit https://phar.phpunit.de/phpunit-8.phar | ||
- chmod +x ./phpunit | ||
- composer install -o | ||
php: | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
- 7.0 | ||
- hhvm | ||
- nightly | ||
after_success: | ||
- CODECLIMATE_REPO_TOKEN=f9c21f5f87187047d967a0f50281bd5b663820942a7b3e914c9d0b19c3d819f3 ./vendor/bin/test-reporter # CodeClimate | ||
- 7.2 | ||
- 7.3 | ||
- 7.4 |
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
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 |
---|---|---|
@@ -1,13 +1,15 @@ | ||
<?php | ||
|
||
use EvanDarwin\JSend\Laravel\Builder\JSendLaravelBuilder; | ||
|
||
return array( | ||
/** | ||
* Configuration file for Laravel JSend. | ||
*/ | ||
|
||
/* | ||
* Default: | ||
* \EvanDarwin\JSend\Laravel\Builder\JSendLaravelBuilder | ||
*/ | ||
'builder' => '\EvanDarwin\JSend\Laravel\Builder\JSendLaravelBuilder', | ||
'builder' => JSendLaravelBuilder::class, | ||
); |
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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
<?php | ||
|
||
abstract class LaravelJSend_TestCase extends \Orchestra\Testbench\TestCase | ||
{ | ||
protected function getPackageProviders($app) | ||
{ | ||
// Set the default builder | ||
$app['config']->set('jsend.builder', '\EvanDarwin\JSend\Laravel\Builder\JSendLaravelBuilder'); | ||
use EvanDarwin\JSend\Laravel\Builder\JSendLaravelBuilder; | ||
use EvanDarwin\JSend\Laravel\ServiceProvider; | ||
use Orchestra\Testbench\TestCase; | ||
|
||
return ['EvanDarwin\JSend\Laravel\ServiceProvider']; | ||
} | ||
abstract class LaravelJSend_TestCase extends TestCase { | ||
protected function getPackageProviders($app): array { | ||
// Set the default builder | ||
$app['config']->set('jsend.builder', JSendLaravelBuilder::class); | ||
return [ServiceProvider::class]; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,65 +1,59 @@ | ||
<?php | ||
|
||
class JSendBuilderTest extends LaravelJSend_TestCase | ||
{ | ||
public function testDefaultValues() | ||
{ | ||
$response = jsend()->get(); | ||
|
||
$this->assertJson(json_encode(array( | ||
'status' => 'success', | ||
'data' => array() | ||
)), $response); | ||
} | ||
|
||
public function testRendersCorrectly() | ||
{ | ||
\Route::get('/jsend', function () { | ||
return jsend()->failed()->code(404)->get(); | ||
}); | ||
|
||
$response = $this->call('get', '/jsend'); | ||
|
||
$this->assertJson(json_encode(array( | ||
'status' => 'failed', | ||
'code' => 404, | ||
'data' => array() | ||
)), $response); | ||
} | ||
|
||
public function testRenderCompatibility() | ||
{ | ||
\Route::get('/jsend', function () { | ||
return jsend()->failed()->code(404)->get(); | ||
}); | ||
|
||
$response = $this->call('get', '/jsend'); | ||
|
||
$this->assertJson(json_encode(array( | ||
'status' => 'failed', | ||
'code' => 404, | ||
'data' => array() | ||
)), $response); | ||
} | ||
|
||
public function testHttpStatus() | ||
{ | ||
\Route::get('/jsend_http', function() { | ||
return jsend()->failed()->code(403)->get(403); | ||
}); | ||
|
||
$response = $this->call('get', '/jsend_http'); | ||
|
||
$this->assertResponseStatus(403); | ||
} | ||
|
||
/** | ||
* @expectedException InvalidArgumentException | ||
*/ | ||
public function testInvalidBuilderException() | ||
{ | ||
$this->app['config']->set('jsend.builder', ''); | ||
|
||
jsend()->get(); | ||
} | ||
use Illuminate\Support\Facades\Route; | ||
|
||
class JSendBuilderTest extends LaravelJSend_TestCase { | ||
public function testDefaultValues(): void { | ||
$response = jsend()->get(); | ||
|
||
$this->assertJson(json_encode(array( | ||
'status' => 'success', | ||
'data' => array() | ||
)), $response); | ||
} | ||
|
||
public function testRendersCorrectly(): void { | ||
Route::get('/jsend', static function () { | ||
return jsend()->failed()->code(404)->get(); | ||
}); | ||
|
||
$response = $this->call('get', '/jsend'); | ||
|
||
$this->assertEquals(json_encode(array( | ||
'status' => 'fail', | ||
'data' => array(), | ||
'errors' => null, | ||
'code' => 404, | ||
)), $response->getContent()); | ||
} | ||
|
||
public function testRenderCompatibility(): void { | ||
Route::get('/jsend', static function () { | ||
return jsend()->failed()->code(404)->get(); | ||
}); | ||
|
||
$response = $this->call('get', '/jsend'); | ||
|
||
$this->assertEquals(json_encode(array( | ||
'status' => 'fail', | ||
'data' => array(), | ||
'errors' => null, | ||
'code' => 404, | ||
)), $response->getContent()); | ||
} | ||
|
||
public function testHttpStatus(): void { | ||
Route::get('/jsend_http', static function () { | ||
return jsend()->failed()->code(403)->get(403); | ||
}); | ||
|
||
$res = $this->call('get', '/jsend_http'); | ||
$this->assertEquals(403, $res->status()); | ||
} | ||
|
||
public function testInvalidBuilderException(): void { | ||
$this->expectException(InvalidArgumentException::class); | ||
$this->app['config']->set('jsend.builder', ''); | ||
jsend()->get(); | ||
} | ||
} |