定制 thirteen/testing 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

thirteen/testing

最新稳定版本:0.2.15

Composer 安装命令:

composer require thirteen/testing

包简介

Testing library for Laravel 5

README 文档

README

Laravel Test Cases is a compilation of traits and test cases to make it manageable to test Models and Repositories.

Installation

Install Composer Dependency

composer require "thirteen/testing:0.2.*" --dev

Install the Service Provider in your config/app.php

Thirteen\Testing\TestingServiceProvider::class

Testing Models

To test models, you can just add the ModelAssertionsTrait in your class.

use App\User;
use Thirteen\Testing\ModelAssertionsTrait;

class UserTest extends TestCase
{
    /** @test **/
    function it_has_many_posts()
    {
        $this->assertHasMany((new User)->posts(), App\Post::class);
    }
}

Assertions

  • assertBelongsTo($relationship, $class, $foreignKey = null);
  • assertBelongsToMany($relationship, $class, $table = null, $foreignKey = null);
  • assertHasMany($relationship, $class, $foreignKey = null);
  • assertHasOne($relationship, $class, $foreignKey = null);

Testing Repositories

I don't really recommend using this since it just extends tests from the repository test case.

If you really want to test all your repository methods then by all means.

use App\User;
use Thirteen\Testing\EloquentRepositoryTestCase;

class UserRepositoryTest extends EloquentRepositoryTestCase
{
    public function repository() {
        return App\Repositories\UserRepository::class;
    }

    public function create() {
        return ['full_name' => 'Jake the Dog'];
    }

    public function update() {
        return ['name' => 'Finn the Human'];
    }
}

Issues

  • I can't seem to make the @before function trait work.

统计信息

  • 总下载量: 166
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-13