Download the PHP package brunty/api-testcase without Composer

On this page you can find all versions of the php package brunty/api-testcase. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package api-testcase

Brunty\ApiTestCase

Build Status Coverage Status SensioLabsInsight

Just some basic helper stuff to help test API endpoints.

Compatibility

Installation

composer require brunty/api-testcase --dev

Usage

Add an environment variable to your PHPUnit Configuration that's your API's base URL:

Extend the \Brunty\ApiTestCase class. If you need to configure the client, call $this->configureClientOptions($options); before calling parent::setUp():

Methods and requests available

The test case uses Guzzle (\GuzzleHttp\Client) under the surface, so requests are effectively just made through that. If you need to access the client, you can do so with $this->client(); within your test class.

GET

get(string $path [, array $options])

POST

post(string $path [, array $options])

PATCH

patch(string $path [, array $options])

PUT

put(string $path [, array $options])

DELETE

delete(string $path [, array $options])

Headers & Responses

getHeader(string $name)

Returns a response header matching the name.

response()

Returns the response object.

statusCode()

Returns the status code from the response.

rawResponseBody()

Returns the contents of the body of the response.

responseBody($asArray)

Returns the response body, parsed into either an array (if $asArray is true) or: \stdClass if the response was JSON, \SimpleXmlElement if the response was XML.

If the content type of the response cannot be determined to be either XML or JSON, a \Brunty\ContentTypeNotFound exception will be thrown.

getContentType()

Returns the value of the first Content-Type header element.

contentTypeIsXml()

Returns true if the content type is XML, false otherwise.

contentTypeIsJson()

Returns true if the content type is JSON, false otherwise.

The \Brunty\Response class contains a list of constants for all HTTP status codes - these can help make status code assertions more readable - for example:

$this->assertResponseStatus(\Brunty\Response::HTTP_NO_CONTENT); as opposed to $this->assertResponseStatus(204);

Assertions

Assertion Notes
assertResponseStatus($status)
assertResponseOk() (Response code 200)
assertResponseWasSuccess() (200 <= Response Code < 300)
assertResponseWasRedirect() (300 <= Response Code < 400) _Note that you may need to set the allow_redirects option to false otherwise status codes of the page after the redirect can be used._
assertResponseWasClientError() (400 <= Response Code < 500)
assertResponseWasServerError() (500 <= Response Code)
assertResponseWasJson()
assertResponseWasXml()
assertResponseHasKey($key)
assertNodeIsValue($xPathQuery, $value) Runs the xpath query against the result (yes, even for JSON - though that's a bit experimental) and asserts that the value is correct - currently only works with strings.
assertRedirectedTo($path) Path can be absolute, or relative to the root api_base_url

Contributing

This started as a project of boredom one Friday evening, if you find yourself using this, and want more features, please feel free to suggest them, or submit a PR!

Although this project is small, openness and inclusivity are taken seriously. To that end the following code of conduct has been adopted.

Contributor Code of Conduct


All versions of api-testcase with dependencies

PHP Build Version
Package Version
Requires php Version 7.0.*||7.1.*
guzzlehttp/guzzle Version ^6.2
spatie/array-to-xml Version ^2.2
phpunit/phpunit Version ^6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package brunty/api-testcase contains the following files

Loading the files please wait ....