Skip to content

Commit

Permalink
Coverage badge
Browse files Browse the repository at this point in the history
  • Loading branch information
oddvalue committed Apr 3, 2024
1 parent d02934b commit 6f7c7aa
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none
coverage: xdebug

- name: Setup problem matchers
run: |
Expand All @@ -55,4 +55,11 @@ jobs:
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Execute tests
run: vendor/bin/pest
run: vendor/bin/pest --coverage-cobertura coverage.xml

- name: Upload coverage
uses: gaelgirodon/ci-badges-action@v1
if: github.ref == 'refs/heads/main'
with:
gist-id: 9dd8e508cb2433728d42a258193770eb
token: ${{ secrets.GIST_TOKEN }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/oddvalue/laravel-drafts/run-tests.yml?label=tests&style=flat-square)](https://github.com/oddvalue/laravel-drafts/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/oddvalue/laravel-drafts/php-cs-fixer.yml?label=code%20style&style=flat-square)](https://github.com/oddvalue/laravel-drafts/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/oddvalue/laravel-drafts.svg?style=flat-square)](https://packagist.org/packages/oddvalue/laravel-drafts)
![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/oddvalue/9dd8e508cb2433728d42a258193770eb/raw/laravel-drafts-cobertura-coverage.json)

* [Installation](#installation)
* [Usage](#usage)
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^9.0|^10.0",
"roave/security-advisories": "dev-latest",
"spatie/invade": "^2.0",
"spatie/pest-plugin-test-time": "^1.0|^2.0",
"spatie/ray": "^1.37"
},
Expand Down
29 changes: 29 additions & 0 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,32 @@
->and($post->getPublisherColumns())->toBe(['id' => $post::PUBLISHER_ID, 'type' => $post::PUBLISHER_TYPE])
->and($post->getQualifiedPublisherColumns())->toBe($post->qualifyColumns(['id' => $post::PUBLISHER_ID, 'type' => $post::PUBLISHER_TYPE]));
});

it('honors column name overrides', function () {

$post = OverridePost::make([

]);
invade($post)->newRevision();

expect($post->getPublishedAtColumn())->toBe('published_at_override')
->and($post->getIsPublishedColumn())->toBe('is_published_override')
->and($post->getIsCurrentColumn())->toBe('is_current_override')
->and($post->getUuidColumn())->toBe('uuid_override')
->and($post->getPublisherColumns())->toBe(['id' => 'publisher_override_id', 'type' => 'publisher_override_type']);
});

class OverridePost extends \Illuminate\Database\Eloquent\Model
{
use \Oddvalue\LaravelDrafts\Concerns\HasDrafts;
use \Illuminate\Database\Eloquent\SoftDeletes;

public const PUBLISHED_AT = 'published_at_override';
public const IS_PUBLISHED = 'is_published_override';
public const IS_CURRENT = 'is_current_override';
public const UUID = 'uuid_override';
public const PUBLISHER_ID = 'publisher_override_id';
public const PUBLISHER_TYPE = 'publisher_override_type';

protected $guarded = [];
}

0 comments on commit 6f7c7aa

Please sign in to comment.