PHP Class Flugg\Responder\Tests\TestCase

Author: Alexander Tømmerås ([email protected])
Inheritance: extends Orchestra\Testbench\TestCase
Datei anzeigen Open project: flugger/laravel-responder

Protected Properties

Property Type Description
$responder Flugg\Responder\Responder An instance of the responder service responsible for generating API responses.
$schema Illuminate\Database\Schema\Builder Save an instance of the schema builder for easy access.

Public Methods

Method Description
setUp ( ) : void Setup the test environment.

Protected Methods

Method Description
createModel ( array $attributes = [] ) : Model Creates a new adjustable model for testing purposes.
createTestController ( ) : Illuminate\Routing\Controller Creates a controller class with the RespondsWithJson trait.
createTestModelWithNoTransformer ( array $attributes = [] ) : Model Creates a new adjustable model without an attached transformer for testing purposes.
createTestModelWithNullTransformer ( array $attributes = [] ) : Model Creates a new adjustable model with a null transformer for testing purposes.
createTestTransformer ( ) : void Creates a new transformer for testing purposes.
getEnvironmentSetUp ( Illuminate\Foundation\Application $app ) : void Define environment setup.
getPackageProviders ( $app ) : array Get package service providers.
makeModel ( array $attributes = [] ) : Model Makes a new empty model for testing purposes.
makeModelWithResourceKey ( string $resourceKey ) : Model Makes a new empty model with a resource key set.
makeModelWithTransformer ( $transformer ) : Model Makes a new empty transformable model with a transformer set.
makeTransformer ( ) : Transformer Makes a new transformer for testing purposes.
mockBuilder ( array $data = null ) : Mockery\MockInterface Create a mock of the Eloquent builder with a mock of the [get] method which returns the given data.
mockBuilderWithPaginator ( array $data = null ) : Mockery\MockInterface Create a mock of the Eloquent builder with a mock of the [paginate] method which returns an instance of [\Illuminate\Pagination\LengthAwarePaginator].
mockPivot ( ) : Mockery\MockInterface Create a mock of a pivot.
mockRelation ( Collection | Model | null $data = null ) : Mockery\MockInterface Create a mock of an Eloquent relationship.
mockResourceFactory ( League\Fractal\Resource\ResourceInterface $resource ) : Mockery\MockInterface Create a mock of a resource factory.
mockResponder ( ) : Mockery\MockInterface Create a mock of the responder and binds it to the service container.
mockSuccessBuilder ( ) : Mockery\MockInterface Create a mock of a success response builder.
mockTranslator ( string $message ) : Mockery\MockInterface Create a mock of Laravel's translator and binds it to the service container.
rollbackTestMigrations ( ) : void Rollback migrations for tables only used for testing purposes.
runTestMigrations ( ) : void Run migrations for tables only used for testing purposes.
storeModel ( Model $model, array $attributes = [] ) : Model Stores an actual instance of an adjustable model to the database.

Method Details

createModel() protected method

Creates a new adjustable model for testing purposes.
protected createModel ( array $attributes = [] ) : Model
$attributes array
return Illuminate\Database\Eloquent\Model

createTestController() protected method

Creates a controller class with the RespondsWithJson trait.
protected createTestController ( ) : Illuminate\Routing\Controller
return Illuminate\Routing\Controller

createTestModelWithNoTransformer() protected method

Creates a new adjustable model without an attached transformer for testing purposes.
protected createTestModelWithNoTransformer ( array $attributes = [] ) : Model
$attributes array
return Illuminate\Database\Eloquent\Model

createTestModelWithNullTransformer() protected method

Creates a new adjustable model with a null transformer for testing purposes.
protected createTestModelWithNullTransformer ( array $attributes = [] ) : Model
$attributes array
return Illuminate\Database\Eloquent\Model

createTestTransformer() protected method

Creates a new transformer for testing purposes.
protected createTestTransformer ( ) : void
return void

getEnvironmentSetUp() protected method

Define environment setup.
protected getEnvironmentSetUp ( Illuminate\Foundation\Application $app ) : void
$app Illuminate\Foundation\Application
return void

getPackageProviders() protected method

Get package service providers.
protected getPackageProviders ( $app ) : array
return array

makeModel() protected method

Makes a new empty model for testing purposes.
protected makeModel ( array $attributes = [] ) : Model
$attributes array
return Illuminate\Database\Eloquent\Model

makeModelWithResourceKey() protected method

Makes a new empty model with a resource key set.
protected makeModelWithResourceKey ( string $resourceKey ) : Model
$resourceKey string
return Illuminate\Database\Eloquent\Model

makeModelWithTransformer() protected method

Makes a new empty transformable model with a transformer set.
protected makeModelWithTransformer ( $transformer ) : Model
return Illuminate\Database\Eloquent\Model

makeTransformer() protected method

Makes a new transformer for testing purposes.
protected makeTransformer ( ) : Transformer
return Flugg\Responder\Transformer

mockBuilder() protected method

Create a mock of the Eloquent builder with a mock of the [get] method which returns the given data.
protected mockBuilder ( array $data = null ) : Mockery\MockInterface
$data array
return Mockery\MockInterface

mockBuilderWithPaginator() protected method

Create a mock of the Eloquent builder with a mock of the [paginate] method which returns an instance of [\Illuminate\Pagination\LengthAwarePaginator].
protected mockBuilderWithPaginator ( array $data = null ) : Mockery\MockInterface
$data array
return Mockery\MockInterface

mockPivot() protected method

Create a mock of a pivot.
protected mockPivot ( ) : Mockery\MockInterface
return Mockery\MockInterface

mockRelation() protected method

Create a mock of an Eloquent relationship.
protected mockRelation ( Collection | Model | null $data = null ) : Mockery\MockInterface
$data Illuminate\Support\Collection | Illuminate\Database\Eloquent\Model | null
return Mockery\MockInterface

mockResourceFactory() protected method

Create a mock of a resource factory.
protected mockResourceFactory ( League\Fractal\Resource\ResourceInterface $resource ) : Mockery\MockInterface
$resource League\Fractal\Resource\ResourceInterface
return Mockery\MockInterface

mockResponder() protected method

Create a mock of the responder and binds it to the service container.
protected mockResponder ( ) : Mockery\MockInterface
return Mockery\MockInterface

mockSuccessBuilder() protected method

Create a mock of a success response builder.
protected mockSuccessBuilder ( ) : Mockery\MockInterface
return Mockery\MockInterface

mockTranslator() protected method

Create a mock of Laravel's translator and binds it to the service container.
protected mockTranslator ( string $message ) : Mockery\MockInterface
$message string
return Mockery\MockInterface

rollbackTestMigrations() protected method

Rollback migrations for tables only used for testing purposes.
protected rollbackTestMigrations ( ) : void
return void

runTestMigrations() protected method

Run migrations for tables only used for testing purposes.
protected runTestMigrations ( ) : void
return void

setUp() public method

Setup the test environment.
public setUp ( ) : void
return void

storeModel() protected method

Stores an actual instance of an adjustable model to the database.
protected storeModel ( Model $model, array $attributes = [] ) : Model
$model Illuminate\Database\Eloquent\Model
$attributes array
return Illuminate\Database\Eloquent\Model

Property Details

$responder protected_oe property

An instance of the responder service responsible for generating API responses.
protected Responder,Flugg\Responder $responder
return Flugg\Responder\Responder

$schema protected_oe property

Save an instance of the schema builder for easy access.
protected Builder,Illuminate\Database\Schema $schema
return Illuminate\Database\Schema\Builder