承接 dillingham/nova-assertions 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

dillingham/nova-assertions

Composer 安装命令:

composer require dillingham/nova-assertions

包简介

Nova api testing requests & assertions

README 文档

README

Latest Version on Github Total Downloads Twitter Follow

Nova requests & assertions for Laravel tests - View examples

testing tdd laravel nova

Assert: Policies | Cards | Actions | Filters | Lenses | Resources | Fields | Relations

Installation

composer require dillingham/nova-assertions --dev

Enable by adding the NovaAssertions to a test

use NovaTesting\NovaAssertions;

class UserTest extends TestCase
{
    use NovaAssertions;
}

Authentication

Log in a user that has access to Nova

$this->be(factory(User::class)->create());

Nova Requests

Request using a resource's uriKey to perform assertions:

$response = $this->novaIndex('users');

$response = $this->novaDetail('users', $user->id);

$response = $this->novaCreate('users');

$response = $this->novaEdit('users', $user->id);

$response = $this->novaLens('users', Lens::class);

Request Filters

You may also pass filters & their values to indexes & lenses

$response = $this->novaIndex('users', [
    StatusFilter::class => 'active'
]);
$response = $this->novaLens('users', Lens::class, [
    StatusFilter::class => 'active'
]);

Assert Http

You can call http response methods as usual:

$response->assertOk();

Assert Resources

$response->assertResourceCount(3);
$response->assertResources(function($resources) {
    return $resources->count() > 0;
});

Assert Cards

$response->assertCardCount(5);
$response->assertCardsInclude(Card::class);
$response->assertCardsExclude(Card::class);
$response->assertCards(function($cards) {
    return $cards->count() > 0;
});

Assert Actions

$response->assertActionCount(5);
$response->assertActionsInclude(Action::class);
$response->assertActionsExclude(Action::class);
$response->assertActions(function($actions) {
    return $actions->count() > 0;
});

Assert Filters

$response->assertFilterCount(5);
$response->assertFiltersInclude(Filter::class);
$response->assertFiltersExclude(Filter::class);
$response->assertFilters(function($filters) {
    return $filters->count() > 0;
});

Assert Lenses

$response->assertLensCount(5);
$response->assertLensesInclude(Lens::class);
$response->assertLensesExclude(Lens::class);
$response->assertLenses(function($lenses) {
    return $lenses->count() > 0;
});

Assert Fields

$response->assertFieldCount(5);

Assert a specific field exists

$response->assertFieldsInclude('id');

Assert a specific field contains a value

$response->assertFieldsInclude('id', $user->id);

Assert multiple fields exist

$response->assertFieldsInclude(['id', 'email']);

Assert multiple fields with specific values exist

$response->assertFieldsInclude(['id' => 1, 'email' => 'example']);

Assert multiple values for one field exist

$response->assertFieldsInclude('id', $users->pluck('id'));

Make assertions against a collection of fields

$response->assertFields(function($fields) {
    return $fields->count() > 0;
});

Also exclude works in all of these scenarios

$response->assertFieldsExclude(['id' => 1, 'email' => 'example']);

Assert Relations

// App\Nova\Post
// BelongsTo::make('Category'),
$response = $this->novaCreate('posts');

$response->assertRelation('categories', function($categories) {
    //
});
// App\Nova\Category
// HasMany::make('Posts'),
$response = $this->novaDetail('categories');

$response->assertRelation('posts', function($posts) {
    //
});

Assert Policies

Assert Nova's use of policies & the authed user:

$response->assertCanView();

$response->assertCanCreate();

$response->assertCanUpdate();

$response->assertCanDelete();

$response->assertCanForceDelete();

$response->assertCanRestore();

Also can assert cannot for each:

$response->assertCannotView();

Author

Hi 👋, Im Brian Dillingham, creator of this Nova package and others

Hope you find it useful. Feel free to reach out with feedback.

Follow me on twitter: @im_brian_d

dillingham/nova-assertions 适用场景与选型建议

dillingham/nova-assertions 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 275.1k 次下载、GitHub Stars 达 78, 最近一次更新时间为 2019 年 08 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 dillingham/nova-assertions 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 dillingham/nova-assertions 我们能提供哪些服务?
定制开发 / 二次开发

基于 dillingham/nova-assertions 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 275.1k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 78
  • 点击次数: 14
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 78
  • Watchers: 3
  • Forks: 15
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-08-17