Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPUnit 10 Shift #507

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
/public/js/location.js.map
/storage/debugbar
/storage/framework/testing
.phpunit.result.cache
/.phpunit.cache
.idea/*
phpunit.xml
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"beyondcode/laravel-dump-server": "^1.9",
"fakerphp/faker": "^1.9.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^6.3",
"phpunit/phpunit": "^9.5.10",
"nunomaduro/collision": "^7.0",
"phpunit/phpunit": "^10.0",
"spatie/laravel-ignition": "^2.0",
"tightenco/duster": "0.3.2"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/Api/ApiTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Laravel\Passport\Passport;
use Tests\TestCase;

class ApiTestCase extends TestCase
final class ApiTestCase extends TestCase
{
use DatabaseTransactions;

Expand Down
11 changes: 6 additions & 5 deletions tests/Api/BioApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Tests\Api;

use PHPUnit\Framework\Attributes\Test;
use App\Models\Bio;

class BioApiTest extends ApiTestCase
final class BioApiTest extends ApiTestCase
{
/** @test */
#[Test]
public function can_fetch_all_user_bios(): void
{
$response = $this->call('GET', '/api/user/1/bios');
Expand All @@ -16,7 +17,7 @@ public function can_fetch_all_user_bios(): void
$this->assertIsArray($data->data);
}

/** @test */
#[Test]
public function can_fetch_one_user_bio(): void
{
$bioId = Bio::first()->id;
Expand All @@ -27,15 +28,15 @@ public function can_fetch_one_user_bio(): void
$this->assertIsObject($data->data);
}

/** @test */
#[Test]
public function cannot_fetch_all_bios_for_other_user(): void
{
$response = $this->call('GET', 'api/user/2/bios');

$this->assertEquals(404, $response->getStatusCode());
}

/** @test */
#[Test]
public function cannot_fetch_one_bio_for_other_user(): void
{
$bioId = Bio::where('user_id', 2)->first()->id;
Expand Down
13 changes: 7 additions & 6 deletions tests/Api/ConferenceApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Tests\Api;

use PHPUnit\Framework\Attributes\Test;
use App\Models\Conference;

class ConferenceApiTest extends ApiTestCase
final class ConferenceApiTest extends ApiTestCase
{
/** @test */
#[Test]
public function can_fetch_all_conferences(): void
{
$response = $this->call('GET', 'api/conferences');
Expand All @@ -16,7 +17,7 @@ public function can_fetch_all_conferences(): void
$this->assertIsArray($data->data);
}

/** @test */
#[Test]
public function can_fetch_one_conference(): void
{
$conferenceId = Conference::first()->id;
Expand All @@ -27,7 +28,7 @@ public function can_fetch_one_conference(): void
$this->assertIsObject($data->data);
}

/** @test */
#[Test]
public function cfp_url_returns_if_set(): void
{
$conference = Conference::create([
Expand All @@ -44,7 +45,7 @@ public function cfp_url_returns_if_set(): void
$this->assertEquals('http://awesome.com/cfp', $data->data->attributes->cfp_url);
}

/** @test */
#[Test]
public function cfp_url_returns_null_on_api_if_not_set(): void
{
$conference = Conference::create([
Expand All @@ -60,7 +61,7 @@ public function cfp_url_returns_null_on_api_if_not_set(): void
$this->assertNull($data->data->attributes->cfp_url);
}

/** @test */
#[Test]
public function unclosed_cfp_returns_open_and_future_cfp(): void
{
Conference::factory()
Expand Down
6 changes: 4 additions & 2 deletions tests/Api/JsonApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace Tests\Api;

class JsonApiTest extends ApiTestCase
use PHPUnit\Framework\Attributes\Test;

final class JsonApiTest extends ApiTestCase
{
/** @test */
#[Test]
public function uses_correct_json_api_header(): void
{
$response = $this->call('GET', '/api/user/1/talks');
Expand Down
6 changes: 4 additions & 2 deletions tests/Api/MeApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace Tests\Api;

class MeApiTest extends ApiTestCase
use PHPUnit\Framework\Attributes\Test;

final class MeApiTest extends ApiTestCase
{
/** @test */
#[Test]
public function can_fetch_my_info(): void
{
$response = $this->call('GET', 'api/me');
Expand Down
19 changes: 10 additions & 9 deletions tests/Api/TalkApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

namespace Tests\Api;

use PHPUnit\Framework\Attributes\Test;
use App\Models\Talk;
use App\Models\TalkRevision;

class TalkApiTest extends ApiTestCase
final class TalkApiTest extends ApiTestCase
{
/** @test */
#[Test]
public function can_fetch_all_talks_for_user(): void
{
$response = $this->call('GET', 'api/user/1/talks');
Expand All @@ -17,7 +18,7 @@ public function can_fetch_all_talks_for_user(): void
$this->assertCount(2, $data->data);
}

/** @test */
#[Test]
public function all_talks_doesnt_return_archived_talks(): void
{
$toBeArchivedTalk = $this->user->talks()->create([]);
Expand All @@ -36,7 +37,7 @@ public function all_talks_doesnt_return_archived_talks(): void
$this->assertCount(2, $data->data);
}

/** @test */
#[Test]
public function including_archived_talks(): void
{
Talk::factory()
Expand All @@ -50,7 +51,7 @@ public function including_archived_talks(): void
$response->assertJsonFragment(['title' => 'My Archived Talk']);
}

/** @test */
#[Test]
public function excluding_archived_talks(): void
{
Talk::factory()
Expand All @@ -64,7 +65,7 @@ public function excluding_archived_talks(): void
$response->assertJsonMissing(['title' => 'My Archived Talk']);
}

/** @test */
#[Test]
public function all_talks_return_alpha_sorted(): void
{
$response = $this->call('GET', 'api/user/1/talks');
Expand All @@ -76,7 +77,7 @@ public function all_talks_return_alpha_sorted(): void
$this->assertEquals('My great talk', $titles->last());
}

/** @test */
#[Test]
public function can_fetch_one_talk(): void
{
$talkId = Talk::first()->id;
Expand All @@ -87,15 +88,15 @@ public function can_fetch_one_talk(): void
$this->assertIsObject($data->data);
}

/** @test */
#[Test]
public function cannot_fetch_all_talks_for_other_users(): void
{
$response = $this->call('GET', 'api/user/2/talks');

$this->assertEquals(404, $response->getStatusCode());
}

/** @test */
#[Test]
public function cannot_fetch_one_talk_for_other_users(): void
{
$talkId = Talk::where('author_id', 2)->first()->id;
Expand Down
11 changes: 6 additions & 5 deletions tests/Console/Commands/TweetImportantCFPDatesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

namespace Tests\Console\Commands;

use PHPUnit\Framework\Attributes\Test;
use App\Console\Commands\TweetImportantCFPDates;
use App\Models\Conference;
use Atymic\Twitter\ApiV1\Service\Twitter;
use Carbon\Carbon;
use Tests\TestCase;

class TweetImportantCFPDatesTest extends TestCase
final class TweetImportantCFPDatesTest extends TestCase
{
/** @test */
#[Test]
public function cfps_opening_today_should_be_tweeted(): void
{
// starts today, ends next week
Expand All @@ -25,7 +26,7 @@ public function cfps_opening_today_should_be_tweeted(): void
(new TweetImportantCFPDates($mock, 0))->handle();
}

/** @test */
#[Test]
public function cfps_closing_tomorrow_should_be_tweeted(): void
{
// started last week, ends tomorrow
Expand All @@ -40,7 +41,7 @@ public function cfps_closing_tomorrow_should_be_tweeted(): void
(new TweetImportantCFPDates($mock, 0))->handle();
}

/** @test */
#[Test]
public function cfps_not_opening_today_nor_closing_tomorrow_should_not_be_tweeted(): void
{
// started last week, ends next week
Expand All @@ -55,7 +56,7 @@ public function cfps_not_opening_today_nor_closing_tomorrow_should_not_be_tweete
(new TweetImportantCFPDates($mock, 0))->handle();
}

/** @test */
#[Test]
public function cfps_that_open_and_close_same_day_should_not_be_tweeted(): void
{
Conference::factory()->create([
Expand Down
7 changes: 4 additions & 3 deletions tests/Feature/AcceptanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tests;

use PHPUnit\Framework\Attributes\Test;
use App\Models\Acceptance;
use App\Models\Conference;
use App\Models\Submission;
Expand All @@ -10,9 +11,9 @@
use App\Models\User;
use Tests\TestCase;

class AcceptanceTest extends TestCase
final class AcceptanceTest extends TestCase
{
/** @test */
#[Test]
public function can_create_from_submission(): void
{
$user = User::factory()->create();
Expand All @@ -36,7 +37,7 @@ public function can_create_from_submission(): void
$this->assertEquals($submission->id, $acceptance->submission->id);
}

/** @test */
#[Test]
public function user_can_remove_acceptance_via_http(): void
{
$user = User::factory()->create();
Expand Down
Loading
Loading