Skip to content

Commit 6f7c7aa

Browse files
committed
Coverage badge
1 parent d02934b commit 6f7c7aa

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

.github/workflows/run-tests.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
with:
4343
php-version: ${{ matrix.php }}
4444
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
45-
coverage: none
45+
coverage: xdebug
4646

4747
- name: Setup problem matchers
4848
run: |
@@ -55,4 +55,11 @@ jobs:
5555
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
5656
5757
- name: Execute tests
58-
run: vendor/bin/pest
58+
run: vendor/bin/pest --coverage-cobertura coverage.xml
59+
60+
- name: Upload coverage
61+
uses: gaelgirodon/ci-badges-action@v1
62+
if: github.ref == 'refs/heads/main'
63+
with:
64+
gist-id: 9dd8e508cb2433728d42a258193770eb
65+
token: ${{ secrets.GIST_TOKEN }}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
[![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)
1111
[![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)
1212
[![Total Downloads](https://img.shields.io/packagist/dt/oddvalue/laravel-drafts.svg?style=flat-square)](https://packagist.org/packages/oddvalue/laravel-drafts)
13+
![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/oddvalue/9dd8e508cb2433728d42a258193770eb/raw/laravel-drafts-cobertura-coverage.json)
1314

1415
* [Installation](#installation)
1516
* [Usage](#usage)

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"phpstan/phpstan-phpunit": "^1.0",
3434
"phpunit/phpunit": "^9.0|^10.0",
3535
"roave/security-advisories": "dev-latest",
36+
"spatie/invade": "^2.0",
3637
"spatie/pest-plugin-test-time": "^1.0|^2.0",
3738
"spatie/ray": "^1.37"
3839
},

tests/ConfigTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,32 @@
4040
->and($post->getPublisherColumns())->toBe(['id' => $post::PUBLISHER_ID, 'type' => $post::PUBLISHER_TYPE])
4141
->and($post->getQualifiedPublisherColumns())->toBe($post->qualifyColumns(['id' => $post::PUBLISHER_ID, 'type' => $post::PUBLISHER_TYPE]));
4242
});
43+
44+
it('honors column name overrides', function () {
45+
46+
$post = OverridePost::make([
47+
48+
]);
49+
invade($post)->newRevision();
50+
51+
expect($post->getPublishedAtColumn())->toBe('published_at_override')
52+
->and($post->getIsPublishedColumn())->toBe('is_published_override')
53+
->and($post->getIsCurrentColumn())->toBe('is_current_override')
54+
->and($post->getUuidColumn())->toBe('uuid_override')
55+
->and($post->getPublisherColumns())->toBe(['id' => 'publisher_override_id', 'type' => 'publisher_override_type']);
56+
});
57+
58+
class OverridePost extends \Illuminate\Database\Eloquent\Model
59+
{
60+
use \Oddvalue\LaravelDrafts\Concerns\HasDrafts;
61+
use \Illuminate\Database\Eloquent\SoftDeletes;
62+
63+
public const PUBLISHED_AT = 'published_at_override';
64+
public const IS_PUBLISHED = 'is_published_override';
65+
public const IS_CURRENT = 'is_current_override';
66+
public const UUID = 'uuid_override';
67+
public const PUBLISHER_ID = 'publisher_override_id';
68+
public const PUBLISHER_TYPE = 'publisher_override_type';
69+
70+
protected $guarded = [];
71+
}

0 commit comments

Comments
 (0)