Skip to content

Commit

Permalink
PHPUnit 10 Migration (#18)
Browse files Browse the repository at this point in the history
* Bump PHPUnit dependencies

* Ignore PHPUnit cache folder

* Add return types to test methods

* Define test classes as `final`

* Move to phpunit.xml.dist

* Remove flags from phpunit test env

* Update PHP min. requirement

---------

Co-authored-by: Shift <shift@laravelshift.com>
  • Loading branch information
olivervogel and laravel-shift authored Feb 28, 2024
1 parent c4fa745 commit 237430f
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 80 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.DS_Store
.phpunit.result.cache
/.phpunit.cache
composer.lock
vendor/
dev/
.phpunit.result.cache
/.phpunit.cache
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.0-cli
FROM php:8.1-cli

RUN apt update \
&& apt install -y \
Expand Down
109 changes: 58 additions & 51 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,58 @@
{
"name": "intervention/zodiac",
"description": "Zodiac sign calculator",
"homepage": "https://zodiac.intervention.io",
"keywords": ["zodiac", "sun sign", "star sign", "horoscope", "astrology", "birthday"],
"license": "MIT",
"authors": [
{
"name": "Oliver Vogel",
"email": "oliver@intervention.io",
"homepage": "https://intervention.io/"
}
],
"require": {
"php": "^8.0",
"nesbot/carbon": "^2.0",
"illuminate/translation": "~6|~7|~8|~9|~10"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"phpstan/phpstan": "^1",
"squizlabs/php_codesniffer": "^3.8",
"slevomat/coding-standard": "~8.0"
},
"autoload": {
"psr-4": {
"Intervention\\Zodiac\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Intervention\\Zodiac\\Test\\": "tests/"
}
},
"extra": {
"laravel": {
"providers": [
"Intervention\\Zodiac\\Laravel\\ZodiacServiceProvider"
],
"aliases": {
"Zodiac": "Intervention\\Zodiac\\Laravel\\ZodiacFacade"
}
}
},
"minimum-stability": "stable",
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
{
"name": "intervention/zodiac",
"description": "Zodiac sign calculator",
"homepage": "https://zodiac.intervention.io",
"keywords": [
"zodiac",
"sun sign",
"star sign",
"horoscope",
"astrology",
"birthday"
],
"license": "MIT",
"authors": [
{
"name": "Oliver Vogel",
"email": "oliver@intervention.io",
"homepage": "https://intervention.io/"
}
],
"require": {
"php": "^8.1",
"nesbot/carbon": "^2.0",
"illuminate/translation": "~6|~7|~8|~9|~10"
},
"require-dev": {
"phpunit/phpunit": "^10.0",
"phpstan/phpstan": "^1",
"squizlabs/php_codesniffer": "^3.8",
"slevomat/coding-standard": "~8.0"
},
"autoload": {
"psr-4": {
"Intervention\\Zodiac\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Intervention\\Zodiac\\Test\\": "tests/"
}
},
"extra": {
"laravel": {
"providers": [
"Intervention\\Zodiac\\Laravel\\ZodiacServiceProvider"
],
"aliases": {
"Zodiac": "Intervention\\Zodiac\\Laravel\\ZodiacFacade"
}
}
},
"minimum-stability": "stable",
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ services:
tests:
build: ./
working_dir: /project
command: bash -c "composer install && ./vendor/bin/phpunit -vvv"
command: bash -c "composer install && ./vendor/bin/phpunit"
volumes:
- ./:/project
coverage:
Expand Down
17 changes: 0 additions & 17 deletions phpunit.xml

This file was deleted.

8 changes: 8 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
8 changes: 4 additions & 4 deletions tests/AbstractZodiacTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
use Intervention\Zodiac\AbstractZodiac;
use PHPUnit\Framework\TestCase;

class AbstractZodiacTest extends TestCase
final class AbstractZodiacTest extends TestCase
{
public function testMatch()
public function testMatch(): void
{
$zodiac = $this->getMockForAbstractClass(AbstractZodiac::class);
$zodiac->start = ['month' => '6', 'day' => '1'];
Expand All @@ -22,15 +22,15 @@ public function testMatch()
$this->assertFalse($zodiac->match(Carbon::create(null, 6, 11)));
}

public function testLocalized()
public function testLocalized(): void
{
$zodiac = $this->getMockForAbstractClass(AbstractZodiac::class);
$zodiac->name = 'gemini';

$this->assertEquals('Gemini', $zodiac->localized());
}

public function testToString()
public function testToString(): void
{
$zodiac = $this->getMockForAbstractClass(AbstractZodiac::class);
$zodiac->name = 'mock';
Expand Down
8 changes: 4 additions & 4 deletions tests/CalculatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
use Intervention\Zodiac\Zodiacs\Virgo;
use PHPUnit\Framework\TestCase;

class CalculatorTest extends TestCase
final class CalculatorTest extends TestCase
{
public function testMake(): void
{
$result = Calculator::make('1979-12-12');
$this->assertInstanceOf(Sagittarius::class, $result);
}

public function testGetZodiacFromString()
public function testGetZodiacFromString(): void
{
$calculator = new Calculator();

Expand All @@ -49,14 +49,14 @@ public function testGetZodiacFromString()
$this->assertInstanceOf(Pisces::class, $calculator->getZodiac('1977-02-27'));
}

public function testMakeInvalidString()
public function testMakeInvalidString(): void
{
$this->expectException(NotReadableException::class);
$calculator = new Calculator();
$calculator->getZodiac('foobar');
}

public function testMakeFromObject()
public function testMakeFromObject(): void
{
$calculator = new Calculator();

Expand Down

0 comments on commit 237430f

Please sign in to comment.