Skip to content

Commit

Permalink
Fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
BadJacky committed Apr 29, 2024
1 parent 611435b commit d8c23cb
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 109 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: >
dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, fileinfo${{ matrix.os != 'windows-latest' && ',pcntl,imagick' || '' }}
coverage: none
extensions: ${{ matrix.os == 'windows-latest' && 'dom, xdebug, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, fileinfo' || 'dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, xdebug,exif, iconv, fileinfo, pcntl, imagick' }}
coverage: xdebug

- name: Setup problem matchers
run: |
Expand All @@ -43,4 +42,11 @@ jobs:
composer install --no-interaction
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Execute tests
run: vendor/bin/pest
run: composer test-coverage
- name: Upload coverage report
uses: actions/upload-artifact@v2
with:
name: coverage-report
path: ./coverage
artifact-name: coverage-report-${{ runner.os }}
artifact-path: ./coverage
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ Homestead.yaml
Homestead.json
/.vagrant
.phpunit.result.cache
coverage/

.DS_Store
12 changes: 3 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "badjacky/basic-type",
"description": "Complext data type ",
"description": "Complex data type ",
"keywords": [
"badjacky",
"basic-type"
Expand Down Expand Up @@ -42,8 +42,8 @@
]
},
"scripts": {
"test": "vendor/bin/phpunit",
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
"test": "vendor/bin/pest",
"test-coverage": "php -d xdebug.mode=coverage vendor/bin/pest --coverage-html coverage"
},
"config": {
"sort-packages": true,
Expand All @@ -55,12 +55,6 @@
"minimum-stability": "stable",
"extra": {
"laravel": {
"providers": [
"BadJacky\\BasicType\\BasicTypeServiceProvider"
],
"aliases": {
"BasicType": "BadJacky\\BasicType\\BasicTypeFacade"
}
}
}
}
1 change: 0 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
</testsuites>
<source>
<include>
<directory suffix=".php">./app</directory>
<directory suffix=".php">./src</directory>
</include>
</source>
Expand Down
12 changes: 6 additions & 6 deletions src/BasicType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,47 @@ public function asInt(): int
if ('integer' !== gettype($this->value)) {
throw new \TypeError('Value is not an integer');
}
return (int)$this->value;
return $this->value;
}

public function asString(): string
{
if ('string' !== gettype($this->value)) {
throw new \TypeError('Value is not a string');
}
return (string)$this->value;
return $this->value;
}

public function asFloat(): float
{
if ('double' !== gettype($this->value)) {
throw new \TypeError('Value is not a float');
}
return (float)$this->value;
return $this->value;
}

public function asArray(): array
{
if ('array' !== gettype($this->value)) {
throw new \TypeError('Value is not an array');
}
return (array)$this->value;
return $this->value;
}

public function asBool(): bool
{
if ('boolean' !== gettype($this->value)) {
throw new \TypeError('Value is not a bool');
}
return (bool)$this->value;
return $this->value;
}

public function asObject(): object
{
if ('object' !== gettype($this->value)) {
throw new \TypeError('Value is not an object');
}
return (object)$this->value;
return $this->value;
}

public function asNull(): null
Expand Down
21 changes: 0 additions & 21 deletions src/BasicTypeFacade.php

This file was deleted.

60 changes: 0 additions & 60 deletions src/BasicTypeServiceProvider.php

This file was deleted.

3 changes: 2 additions & 1 deletion src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace BadJacky\BasicType;


function type(mixed $value): \BadJacky\BasicType\BasicType
{
return app('basic-type')->setValue($value);
return app(BasicType::class)->setValue($value);
}
4 changes: 0 additions & 4 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,4 @@ abstract class TestCase extends BaseTestCase
{
use CreatesApplication;

protected function getPackageProviders($app): array
{
return [BasicTypeServiceProvider::class];
}
}
7 changes: 4 additions & 3 deletions tests/Unit/BasicTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
type(new stdClass())->asBool();
})->throws(TypeError::class);

it('produces the same result with type function and setValue method', function () {
expect(type(123))
->toBe(app('basic-type')->setValue(123));
it('produces the same result with type function and setValue method to get value', function () {

expect(type(123)->asInt())
->toBe(app(\BadJacky\BasicType\BasicType::class)->setValue(123)->asInt());
});

0 comments on commit d8c23cb

Please sign in to comment.