PHP REST Client Framework Control: Testing and validating REST services

Recommend this page to a friend!
  Info   View files (234)   Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 151 All time: 8,825 This week: 306
Version License PHP version Categories
rest-control 1.0.0MIT/X Consortium ...5HTTP, PHP 5, Web services, Testing
Description Author

This package can be used for testing and validating REST services.

It can configure and send HTTP requests using different methods like POST, GET, PUT, DELETE, HEAD, PATCH, PURGE, OPTIONS, TRACE and CONNECT. It supports:

- Emulate form submission
- Configure request headers
- Perform basic HTTP authentication
- oAuth protocol
- JSON response status and body validation
- Describe test details using annotations
- Measure the response time and retrieve test statistics
- Etc.

Picture of Kamil
  Performance   Level  
Name: Kamil <contact>
Classes: 1 package by
Country: Poland Poland
Age: ???
All time rank: 415699 in Poland Poland
Week rank: 762 18 in Poland Poland

Details

RestControl

About RestControl(Twitter)

RestControl is modern and powerful framework for testing REST services. RestControl provides set of tools for describing HTTP requests and responses in expressive and elegant way.

Latest Stable Version Latest Unstable Version License Build status Build Status

Examples

Here is a simple example of how to send a GET request and validate json response:

 /
  * @test(
  *     title="Example test",
  *     description="Example test description",
  *     tags="find user"
  * )
  */
 public function exampleFindUser()
 {
    return send()->get('https://jsonplaceholder.typicode.com/users/1')
                 ->expectedResponse()
                 ->httpStatusOk()
                 ->json()
                 ->jsonPath('$.address.street', endsWith('Light'));
 }

Features/Helpers

  • Easily sending HTTP Requests, variety of http methods like post, get, put, delete, head, patch, purge, options, trace, connect
  • forms
  • request headers
  • basic HTTP authentication
  • oAuth && oAuth2 authentication(in progress)
  • JSON response validation
  • JSON Path body validation
  • easily JSON body items and collection of items validation
  • sets of http response code helpers like httpStatusOk, httpBadGateway etc.
  • easily to use expression language - iteration over body items - values comparing (e.g. equalsTo, lessThan) - string validation (e.g. startsWith, endsWith) - custom validation via closure
  • annotations describing tests
  • measuring response time and tests statistics
  • XML validation(in progress)
  • easily system of tests environments
  • json, html reporting system(in progress)
  • cookies(in progress)
  • proxy, ssl support(in progress)
  • command for automatic generation of tests

Quick Start

The best way for quick start is to use RestControl standalone application. You can find it here https://github.com/rest-control/standalone-testing-application. If you want to save yourself the hassle of installing dependencies required for this project on your local machine, you can use Docker containers as an alternative. Note that you will need Docker and Docker Compose in version >= 2.1.

To build and start RestControl standalone application, run following commands:

user@user:~/projects/standalone-testing-application$ make build
user@user:~/projects/standalone-testing-application$ make start

Now, you can use Docker machine and run example tests.

user@user:~/projects/standalone-testing-application$ docker exec -it restcontrol_cli_1 bash
user@machineid:/app# php vendor/bin/rest-control run

Contributing

Thank you if you considering contributing to RestControl! The contribution guide will be available soon. Start watching this project to get regular updates.

Project roadmap

All planned releases you can find here: https://github.com/rest-control/rest-control/milestones.

Learning RestControl

RestControl documentation is under construction, please be patient. Current documentation files are available on https://rest-control.github.io/

  Files  
File Role Description
.github (3 files)
bin (1 file)
src (1 file, 8 directories)
tests (2 files, 7 directories)
.coveralls.yml Data Auxiliary data
.php_cs.dist Example Example script
.travis.yml Data Auxiliary data
appveyor.yml Data Auxiliary data
CHANGELOG.md Data Auxiliary data
composer.json Data Auxiliary data
CONTRIBUTING.md Data Auxiliary data
LICENSE Lic. License text
phpunit.xml.dist Data Auxiliary data
README.md Doc. Documentation
rest-control.yml-sample Data Auxiliary data

  Files  /  .github  
File Role Description
   ISSUE_TEMPLATE.md Data Auxiliary data
   PULL_REQUEST_TEMPLATE.md Data Auxiliary data
   rest-control.jpg Icon Icon image

  Files  /  bin  
File Role Description
   rest-control Example Example script

  Files  /  src  
File Role Description
ApiClient (5 files)
Console (1 file, 2 directories)
Loader (4 files, 1 directory)
TestCase (9 files, 5 directories)
TestCasePipeline (5 files, 3 directories)
Traits (1 file)
Utils (4 files)
Validators (18 files)
   helpers.php Example Example script

  Files  /  src  /  ApiClient  
File Role Description
   ApiClientInterface.php Class Class source
   ApiClientRequest.php Class Class source
   ApiClientResponse.php Class Class source
   HttpGuzzleClient.php Class Class source
   MockApiClient.php Class Class source

  Files  /  src  /  Console  
File Role Description
Commands (3 files)
Utils (1 file)
   Console.php Class Class source

  Files  /  src  /  Console  /  Commands  
File Role Description
   CreateTestCaseCommand.php Class Class source
   HelpersTrait.php Class Class source
   RunTestsCommand.php Class Class source

  Files  /  src  /  Console  /  Utils  
File Role Description
   ConsoleTestCasePipelineListener.php Class Class source

  Files  /  src  /  Loader  
File Role Description
Annotations (2 files)
   LoaderInterface.php Class Class source
   PsrClassLoader.php Class Class source
   TestCaseDelegate.php Class Class source
   TestsBag.php Class Class source

  Files  /  src  /  Loader  /  Annotations  
File Role Description
   AnnotationInterface.php Class Class source
   TestAnnotation.php Class Class source

  Files  /  src  /  TestCase  
File Role Description
ExpressionLanguage (10 files)
ResponseFilters (9 files, 1 directory)
StatsCollector (3 files)
Stubs (2 files)
Traits (4 files)
   AbstractChain.php Class Class source
   AbstractTestCase.php Class Class source
   ChainObject.php Class Class source
   ChainTrait.php Class Class source
   Request.php Class Class source
   Response.php Class Class source
   ResponseFiltersBag.php Class Class source
   StubGenerator.php Class Class source
   TestCaseEventsInterface.php Class Class source

  Files  /  src  /  TestCase  /  ExpressionLanguage  
File Role Description
   ContainsString.php Class Class source
   EachItems.php Class Class source
   EndsWith.php Class Class source
   EqualsTo.php Class Class source
   Expression.php Class Class source
   ExpressionValidatorInterface.php Class Class source
   LessThan.php Class Class source
   MoreThan.php Class Class source
   StartsWith.php Class Class source
   Validators.php Class Class source

  Files  /  src  /  TestCase  /  ResponseFilters  
File Role Description
HttpCodes (53 files)
   AbstractFilter.php Class Class source
   FilterInterface.php Class Class source
   FilterTrait.php Class Class source
   HasItemFilter.php Class Class source
   HasItemsFilter.php Class Class source
   HeaderFilter.php Class Class source
   HttpCode.php Class Class source
   JsonFilter.php Class Class source
   JsonPathFilter.php Class Class source

  Files  /  src  /  TestCase  /  ResponseFilters  /  HttpCodes  
File Role Description
   AbstractPredefinedHttpCode.php Class Class source
   HttpAccepted.php Class Class source
   HttpBadGateway.php Class Class source
   HttpBadRequest.php Class Class source
   HttpBandwidthLimitExceeded.php Class Class source
   HttpConflict.php Class Class source
   HttpConnectionRefused.php Class Class source
   HttpConnectionTimedOut.php Class Class source
   HttpContinue.php Class Class source
   HttpCreated.php Class Class source
   HttpExpectationFailed.php Class Class source
   HttpForbidden.php Class Class source
   HttpFound.php Class Class source
   HttpGatewayTimeout.php Class Class source
   HttpGone.php Class Class source
   HttpHttpVersionNotSupported.php Class Class source
   HttpImATeapot.php Class Class source
   HttpInsufficientStorage.php Class Class source
   HttpInternalServerError.php Class Class source
   HttpLengthRequired.php Class Class source
   HttpLoopDetected.php Class Class source
   HttpMethodNotAllowed.php Class Class source
   HttpMovedPermanently.php Class Class source
   HttpMultipleChoices.php Class Class source
   HttpNetworkAuthenticationRequired.php Class Class source
   HttpNoContent.php Class Class source
   HttpNonAuthoritativeInformation.php Class Class source
   HttpNotAcceptable.php Class Class source
   HttpNotExtended.php Class Class source
   HttpNotFound.php Class Class source
   HttpNotImplemented.php Class Class source
   HttpNotModified.php Class Class source
   HttpOk.php Class Class source
   HttpPartialContent.php Class Class source
   HttpPaymentRequired.php Class Class source
   HttpPreconditionFailed.php Class Class source
   HttpProxyAuthenticationRequired.php Class Class source
   HttpRequestedRangeNotSatisfiable.php Class Class source
   HttpRequestEntityTooLarge.php Class Class source
   HttpRequestTimeout.php Class Class source
   HttpRequestUriTooLong.php Class Class source
   HttpResetContent.php Class Class source
   HttpSeeOther.php Class Class source
   HttpServiceUnavailable.php Class Class source
   HttpSwitchingProtocols.php Class Class source
   HttpSwitchProxy.php Class Class source
   HttpTemporaryRedirect.php Class Class source
   HttpTooManyRedirects.php Class Class source
   HttpUnauthorized.php Class Class source
   HttpUnavailableForLegalReasons.php Class Class source
   HttpUnsupportedMediaType.php Class Class source
   HttpUseProxy.php Class Class source
   HttpVariantAlsoNegotiates.php Class Class source

  Files  /  src  /  TestCase  /  StatsCollector  
File Role Description
   EndContextException.php Class Class source
   StatsCollector.php Class Class source
   StatsCollectorInterface.php Class Class source

  Files  /  src  /  TestCase  /  Stubs  
File Role Description
   TestCase.php.stub Class Class source
   TestCaseMethod.php.stub Data Auxiliary data

  Files  /  src  /  TestCase  /  Traits  
File Role Description
   RequestAuthTrait.php Class Class source
   RequestMethodsTrait.php Class Class source
   RequestTrait.php Class Class source
   ResponseHttpCodesTrait.php Class Class source

  Files  /  src  /  TestCasePipeline  
File Role Description
Adapters (1 file)
Events (6 files)
Stages (2 files)
   Payload.php Class Class source
   TestCasePipeline.php Class Class source
   TestObject.php Class Class source
   TestPipelineConfiguration.php Class Class source
   TestSuiteObject.php Class Class source

  Files  /  src  /  TestCasePipeline  /  Adapters  
File Role Description
   ApiClientRequestAdapter.php Class Class source

  Files  /  src  /  TestCasePipeline  /  Events  
File Role Description
   AfterTestCaseEvent.php Class Class source
   AfterTestCasePipelineEvent.php Class Class source
   AfterTestsSuiteEvent.php Class Class source
   BeforeTestCaseEvent.php Class Class source
   BeforeTestCasePipelineEvent.php Class Class source
   BeforeTestsSuiteEvent.php Class Class source

  Files  /  src  /  TestCasePipeline  /  Stages  
File Role Description
   PrepareTestsSuiteObjectsStage.php Class Class source
   RunTestObjectsStage.php Class Class source

  Files  /  src  /  Traits  
File Role Description
   DirTrait.php Class Class source

  Files  /  src  /  Utils  
File Role Description
   AbstractResponseItem.php Class Class source
   Arr.php Class Class source
   MockApiResponseInterface.php Class Class source
   ResponseItemsCollection.php Class Class source

  Files  /  src  /  Validators  
File Role Description
   AbstractValidatorAdapter.php Class Class source
   ArrayValidatorAdapter.php Class Class source
   DateValidatorAdapter.php Class Class source
   EmailValidatorAdapter.php Class Class source
   Factory.php Class Class source
   FloatValidatorAdapter.php Class Class source
   HostnameValidatorAdapter.php Class Class source
   IBANValidatorAdapter.php Class Class source
   IntValidatorAdapter.php Class Class source
   IPValidatorAdapter.php Class Class source
   ISBNValidatorAdapter.php Class Class source
   LengthValidatorAdapter.php Class Class source
   NotEmptyValidatorAdapter.php Class Class source
   NumericValidatorAdapter.php Class Class source
   RegexValidatorAdapter.php Class Class source
   StringValidatorAdapter.php Class Class source
   URIValidatorAdapter.php Class Class source
   UUIDValidatorAdapter.php Class Class source

  Files  /  tests  
File Role Description
ApiClient (1 file)
Loader (3 files, 1 directory)
TestCase (10 files, 3 directories)
TestCasePipeline (5 files, 3 directories)
Traits (1 file)
Utils (4 files)
Validators (16 files)
   GlobalHelperTest.php Class Class source
   TestsBootstrap.php Example Example script

  Files  /  tests  /  ApiClient  
File Role Description
   MockApiClientTest.php Class Class source

  Files  /  tests  /  Loader  
File Role Description
SamplePathWithTestsCase (2 files, 1 directory)
   PsrClassLoaderTest.php Class Class source
   TestCaseDelegateTest.php Class Class source
   TestsBagTest.php Class Class source

  Files  /  tests  /  Loader  /  SamplePathWithTestsCase  
File Role Description
Rec (1 file, 1 directory)
   SampleFile.php Class Class source
   SampleTest.php Class Class source

  Files  /  tests  /  Loader  /  SamplePathWithTestsCase  /  Rec  
File Role Description
Rec (1 file)
   SampleTest.php Class Class source

  Files  /  tests  /  Loader  /  SamplePathWithTestsCase  /  Rec  /  Rec  
File Role Description
   SampleTest.php Class Class source

  Files  /  tests  /  TestCase  
File Role Description
ExpressionLanguage (8 files)
ResponseFilters (10 files)
StatsCollector (1 file)
   AbstractTestCaseTest.php Class Class source
   ChainObjectTest.php Class Class source
   ChainTraitTest.php Class Class source
   RequestTest.php Class Class source
   ResponseFiltersBagTest.php Class Class source
   ResponseTest.php Class Class source
   SampleTestCase.php Class Class source
   StubGeneratorTest.php Class Class source
   TestResponseChain.php Class Class source
   UnsupportedChain.php Class Class source

  Files  /  tests  /  TestCase  /  ExpressionLanguage  
File Role Description
   ContainsStringTest.php Class Class source
   EachItemsTest.php Class Class source
   EndsWithTest.php Class Class source
   EqualsToTest.php Class Class source
   ExpressionTest.php Class Class source
   LessThanTest.php Class Class source
   MoreThanTest.php Class Class source
   StartsWithTest.php Class Class source

  Files  /  tests  /  TestCase  /  ResponseFilters  
File Role Description
   FilterTraitTest.php Class Class source
   HasItemsTest.php Class Class source
   HasItemTest.php Class Class source
   HeaderFilterTest.php Class Class source
   HttpCodeTest.php Class Class source
   HttpPredefinedCodesTest.php Class Class source
   JsonFilterTest.php Class Class source
   JsonPathFilterTest.php Class Class source
   SampleResponseItem.php Class Class source
   SampleResponseItemAnother.php Class Class source

  Files  /  tests  /  TestCase  /  StatsCollector  
File Role Description
   StatsCollectorTest.php Class Class source

  Files  /  tests  /  TestCasePipeline  
File Role Description
Adapters (1 file)
Events (6 files)
Stages (3 files)
   PayloadTest.php Class Class source
   TestCasePipelineTest.php Class Class source
   TestObjectTest.php Class Class source
   TestPipelineConfigurationTest.php Class Class source
   TestSuiteObjectTest.php Class Class source

  Files  /  tests  /  TestCasePipeline  /  Adapters  
File Role Description
   ApiClientRequestAdapterTest.php Class Class source

  Files  /  tests  /  TestCasePipeline  /  Events  
File Role Description
   AfterTestCaseEventTest.php Class Class source
   AfterTestCasePipelineEventTest.php Class Class source
   AfterTestsSuiteEventTest.php Class Class source
   BeforeTestCaseEventTest.php Class Class source
   BeforeTestCasePipelineEventTest.php Class Class source
   BeforeTestsSuiteEventTest.php Class Class source

  Files  /  tests  /  TestCasePipeline  /  Stages  
File Role Description
   AnotherTestCase.php Class Class source
   PrepareTestsSuiteObjectsStageTest.php Class Class source
   SampleTestCase.php Class Class source

  Files  /  tests  /  Traits  
File Role Description
   DriTraitTest.php Class Class source

  Files  /  tests  /  Utils  
File Role Description
   AbstractResponseItemTest.php Class Class source
   ArrTest.php Class Class source
   ResponseItemsCollectionTest.php Class Class source
   SampleResponseItem.php Class Class source

  Files  /  tests  /  Validators  
File Role Description
   ArrayValidatorAdapterTest.php Class Class source
   DateValidatorAdapterTest.php Class Class source
   EmailValidatorAdapterTest.php Class Class source
   FactoryTest.php Class Class source
   FloatValidatorAdapterTest.php Class Class source
   HostnameValidatorAdapterTest.php Class Class source
   IBANValidatorAdapterTest.php Class Class source
   IntValidatorAdapterTest.php Class Class source
   IPValidatorAdapterTest.php Class Class source
   ISBNValidatorAdapterTest.php Class Class source
   LengthValidatorAdapterTest.php Class Class source
   NotEmptyValidatorAdapterTest.php Class Class source
   NumericValidatorAdapterTest.php Class Class source
   RegexValidatorAdapterTest.php Class Class source
   StringValidatorAdapterTest.php Class Class source
   URIValidatorAdapterTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:151
This week:0
All time:8,825
This week:306

For more information send a message to info at phpclasses dot org.