Skip to content

Commit

Permalink
Fix + drop buildHook for makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
johanvanhelden committed Sep 26, 2024
1 parent 267e8c7 commit 5189e2c
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 96 deletions.
9 changes: 3 additions & 6 deletions app/Data/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,10 @@ private static function isRecentlyUpdated(array $project): bool
return false;
}

$daysSinceUpdate = Carbon::now()->diffInDays($project['updated_at']);
$updatedAt = Carbon::parse($project['updated_at']);
$consideredOldIfAfter = Carbon::now()->subDays(7);

if ($daysSinceUpdate <= 7) {
return true;
}

return false;
return $updatedAt->gte($consideredOldIfAfter);
}

private static function publishAtDisplay(array $project): ?string
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AppServiceProvider extends ServiceProvider
{
public function boot(): void
{
if ($this->app->environment((array) config('environment.development'))) {
if ($this->app->environment(config('environment.development'))) {
Model::shouldBeStrict();
}

Expand Down
50 changes: 0 additions & 50 deletions buildHook.sh

This file was deleted.

4 changes: 4 additions & 0 deletions config/ide-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

declare(strict_types=1);

use App\Models\User;

return [
/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -153,6 +155,8 @@
*/

'ignored_models' => [
// Just a placeholder model - we don't use a database.
User::class,
],

/*
Expand Down
20 changes: 3 additions & 17 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ code-quality: vendor syntax stan md
code-style: vendor node_modules cs cs-fix-dry validate-fe

syntax:
@find app config database lang routes tests -name "*.php" -print0 | xargs -0 -n1 -P8 php -l
@find app config lang routes tests -name "*.php" -print0 | xargs -0 -n1 -P8 php -l

stan: vendor
@vendor/bin/phpstan analyse --memory-limit=2G --configuration=phpstan.neon
Expand All @@ -82,17 +82,10 @@ cs: vendor
@phpcs --standard=./phpcs.xml -p

cs-fix: vendor
@php-cs-fixer fix app config database lang routes tests --diff --config=.php-cs-fixer.php
@php-cs-fixer fix app config lang routes tests --diff --config=.php-cs-fixer.php

cs-fix-dry: vendor
@php-cs-fixer fix app config database lang routes tests --dry-run --diff --config=.php-cs-fixer.php

validate-scripts: node_modules
@make set-nvm

@npm run validate:scripts

@make set-nvm-default
@php-cs-fixer fix app config lang routes tests --dry-run --diff --config=.php-cs-fixer.php

validate-styles: node_modules
@make set-nvm
Expand All @@ -101,13 +94,6 @@ validate-styles: node_modules

@make set-nvm-default

fix-scripts: node_modules
@make set-nvm

@npm run fix:scripts

@make set-nvm-default

fix-styles: node_modules
@make set-nvm

Expand Down
2 changes: 1 addition & 1 deletion resources/data/projects.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/johanvanhelden/dockerhero",
"publish_at": "2019-12-27 12:00:00",
"created_at": "2019-12-27 17:00:51",
"updated_at": "2020-01-10 22:43:58"
"updated_at": "2020-09-25 22:43:58"
},
{
"name": "Personal website",
Expand Down
3 changes: 2 additions & 1 deletion tests/Feature/Page/Home/HomeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

namespace Tests\Feature\Page\Home;

use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class HomeTest extends TestCase
{
/** @test */
#[Test]
public function it_works(): void
{
$this->get(route('page.home'))
Expand Down
5 changes: 3 additions & 2 deletions tests/Feature/Page/Home/ProjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
use Carbon\Carbon;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\File;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class ProjectTest extends TestCase
{
/** @test */
#[Test]
public function has_projects(): void
{
$this->get(route('page.home'))
->assertViewHas('projects');
}

/** @test */
#[Test]
public function it_only_lists_published(): void
{
File::partialMock()
Expand Down
5 changes: 3 additions & 2 deletions tests/Feature/Page/Home/ToolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
use Carbon\Carbon;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\File;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class ToolTest extends TestCase
{
/** @test */
#[Test]
public function has_tools(): void
{
$this->get(route('page.home'))
->assertViewHas('tools');
}

/** @test */
#[Test]
public function it_only_lists_published(): void
{
File::partialMock()
Expand Down
9 changes: 5 additions & 4 deletions tests/Feature/Page/Project/ShowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
use App\Data\Project;
use Carbon\Carbon;
use Illuminate\Support\Facades\File;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class ShowTest extends TestCase
{
/** @test */
#[Test]
public function it_works(): void
{
$project = Project::all()[0];
Expand All @@ -22,7 +23,7 @@ public function it_works(): void
->assertOk();
}

/** @test */
#[Test]
public function it_contains_the_project_data(): void
{
$project = Project::all()[0];
Expand All @@ -33,7 +34,7 @@ public function it_contains_the_project_data(): void
->assertViewHas('project', $project);
}

/** @test */
#[Test]
public function an_unpublished_project_can_not_be_viewed(): void
{
File::partialMock()
Expand All @@ -57,7 +58,7 @@ public function an_unpublished_project_can_not_be_viewed(): void
->assertStatus(403);
}

/** @test */
#[Test]
public function a_published_project_can_not_be_viewed_if_in_the_future(): void
{
File::partialMock()
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Data/Project/ContentDisplayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

use App\Data\Project;
use Illuminate\Support\Facades\File;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class ContentDisplayTest extends TestCase
{
/** @test */
#[Test]
public function markdown_is_converted_to_html(): void
{
File::partialMock()
Expand Down
9 changes: 5 additions & 4 deletions tests/Unit/Data/Project/IsUpdatedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Data\Project;
use Carbon\Carbon;
use Illuminate\Support\Facades\File;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class IsUpdatedTest extends TestCase
Expand All @@ -18,7 +19,7 @@ protected function setUp(): void
Carbon::setTestNow(Carbon::parse('10-10-1989 06:45:10'));
}

/** @test */
#[Test]
public function is_marked_if_edited_the_day_after_being_published(): void
{
File::partialMock()
Expand All @@ -39,7 +40,7 @@ public function is_marked_if_edited_the_day_after_being_published(): void
$this->assertTrue($project['is_updated']);
}

/** @test */
#[Test]
public function is_not_marked_if_not_published(): void
{
File::partialMock()
Expand All @@ -60,7 +61,7 @@ public function is_not_marked_if_not_published(): void
$this->assertFalse($project['is_updated']);
}

/** @test */
#[Test]
public function is_not_marked_if_edit_on_the_same_day_as_being_published(): void
{
File::partialMock()
Expand All @@ -81,7 +82,7 @@ public function is_not_marked_if_edit_on_the_same_day_as_being_published(): void
$this->assertFalse($project['is_updated']);
}

/** @test */
#[Test]
public function is_not_marked_if_updated_before_the_day_of_publishing(): void
{
File::partialMock()
Expand Down
15 changes: 8 additions & 7 deletions tests/Unit/Data/Project/RecentlyUpdatedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Data\Project;
use Carbon\Carbon;
use Illuminate\Support\Facades\File;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class RecentlyUpdatedTest extends TestCase
Expand All @@ -18,7 +19,7 @@ protected function setUp(): void
Carbon::setTestNow(Carbon::parse('10-10-1989 06:45:10'));
}

/** @test */
#[Test]
public function is_marked_if_updated_7_days_ago(): void
{
File::partialMock()
Expand All @@ -39,7 +40,7 @@ public function is_marked_if_updated_7_days_ago(): void
$this->assertTrue($project['is_recently_updated']);
}

/** @test */
#[Test]
public function is_marked_if_updated_3_days_ago(): void
{
File::partialMock()
Expand All @@ -60,7 +61,7 @@ public function is_marked_if_updated_3_days_ago(): void
$this->assertTrue($project['is_recently_updated']);
}

/** @test */
#[Test]
public function is_marked_if_updated_1_day_ago(): void
{
File::partialMock()
Expand All @@ -81,7 +82,7 @@ public function is_marked_if_updated_1_day_ago(): void
$this->assertTrue($project['is_recently_updated']);
}

/** @test */
#[Test]
public function is_not_marked_if_updated_on_the_same_day_as_publishing(): void
{
File::partialMock()
Expand All @@ -102,7 +103,7 @@ public function is_not_marked_if_updated_on_the_same_day_as_publishing(): void
$this->assertFalse($project['is_recently_updated']);
}

/** @test */
#[Test]
public function is_not_marked_if_updated_8_days_ago(): void
{
File::partialMock()
Expand All @@ -123,7 +124,7 @@ public function is_not_marked_if_updated_8_days_ago(): void
$this->assertFalse($project['is_recently_updated']);
}

/** @test */
#[Test]
public function is_not_marked_if_not_published(): void
{
File::partialMock()
Expand All @@ -144,7 +145,7 @@ public function is_not_marked_if_not_published(): void
$this->assertFalse($project['is_recently_updated']);
}

/** @test */
#[Test]
public function is_not_marked_if_not_updated(): void
{
File::partialMock()
Expand Down

0 comments on commit 5189e2c

Please sign in to comment.