lanin / laravel-extend-testcase

为默认的Laravel 5.1 TestCase添加更多功能。

dev-master 2015-07-21 13:37 UTC

This package is auto-updated.

Last update: 2024-09-07 19:56:08 UTC


README

为默认的Laravel 5.1 TestCase添加更多功能。

安装

需要PHP 5.5.9+ 或 HHVM 3.3+,以及Composer 和 Laravel 5.1+。

要获取Laravel-Extend-TestCase的最新版本,只需将以下行添加到您的composer.json文件的require块中。

"lanin/laravel-extend-testcase": "dev-master"

然后您需要运行composer installcomposer update来下载它并更新自动加载器。

安装后,您不需要注册任何ServiceProvider、Facade或发布任何配置。

您只需要将基类 Seeder 扩展为 \Lanin\TestCase\TestCase,然后您就可以开始测试了!

class TestCase extends \Lanin\TestCase\TestCase

API

/**
 * Fin or create first user (id => 1).
 *
 * @return \Illuminate\Contracts\Auth\Authenticatable|static
 */
protected function firstUser();

/**
 * Act like the first user.
 *
 * @return $this
 */
protected function actingAsFirstUser();

/**
 * Asserts that the response JSON contains the given path.
 * Example: $this->seeJsonMatchesPath('$.user.email');
 *
 * @param  string $path
 * @return $this
 * @throws PHPUnitException
 */
protected function seeJsonMatchesPath($path);

/**
 * Return value from the resulting JSON by path.
 * Example: $email = $this->getValueFromJsonByPath('$.user.email');
 *
 * @param  string  $path
 * @return mixed
 */
protected function getValueFromJsonByPath($path);

/**
 * Asserts that the response doesn't contain the given header.
 *
 * @param  string $headerName
 * @return $this
 */
protected function dontSeeHeader($headerName);

/**
 * Asserts that the response doesn't contain the given cookie.
 *
 * @param  string $cookieName
 * @return $this
 */
protected function dontSeeCookie($cookieName);

贡献

请随意将此包进行分支并提交一个pull request来增强其功能。