Skip to content

Commit

Permalink
fix some stan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim-the-Diamond committed Aug 29, 2024
1 parent 14d08a4 commit a99b5c5
Show file tree
Hide file tree
Showing 20 changed files with 226 additions and 60 deletions.
1 change: 1 addition & 0 deletions .phpunit.cache/test-results
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"pest_2.35.1","defects":[],"times":{"Tests\\Unit\\ExampleTest::testThatTrueIsTrue":0.028,"P\\Packages\\core\\tests\\Unit\\ExampleTest::__pest_evaluable_core_example_unit":0.089,"Tests\\Feature\\LandingPageTest::testHealthyResponse":0.169,"Tests\\Feature\\LandingPageTest::testContainsWelcome":0.008,"P\\Tests\\Feature\\MooxLoginTest::__pest_evaluable_healthy_response":0.008,"P\\Tests\\Feature\\MooxLoginTest::__pest_evaluable_it_redirects_to_login":1.046,"P\\Tests\\Feature\\MooxLoginTest::__pest_evaluable_it_contains_Sign_in":1.141,"P\\Tests\\Feature\\PressLoginTest::__pest_evaluable_healthy_response":1.077,"P\\Tests\\Feature\\PressLoginTest::__pest_evaluable_it_redirects_to_login":1.04,"P\\Tests\\Feature\\PressLoginTest::__pest_evaluable_it_contains_Sign_in":1.165,"P\\Packages\\core\\tests\\Feature\\ExampleTest::__pest_evaluable_core_example_feature":0}}
29 changes: 26 additions & 3 deletions packages/flags/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests"
"Tests\\": "tests",
"Workbench\\App\\": "workbench/app/",
"Workbench\\Database\\Factories\\": "workbench/database/factories/",
"Workbench\\Database\\Seeders\\": "workbench/database/seeders/"
}
},
"extra": {
Expand All @@ -47,5 +50,25 @@
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"@clear",
"@prepare"
],
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
"prepare": "@php vendor/bin/testbench package:discover --ansi",
"build": "@php vendor/bin/testbench workbench:build --ansi",
"serve": [
"Composer\\Config::disableProcessTimeout",
"@build",
"@php vendor/bin/testbench serve --ansi"
],
"lint": [
"@php vendor/bin/phpstan analyse --verbose --ansi"
],
"test": [
"@php vendor/bin/phpunit"
]
}
}
3 changes: 3 additions & 0 deletions packages/flags/resources/svg/flag.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 18 additions & 22 deletions packages/flags/tests/CompilesIconsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,57 @@

namespace Tests;

use BladeUI\Heroicons\BladeHeroiconsServiceProvider;
use Moox\Flags\FlagsServiceProvider;
use BladeUI\Icons\BladeIconsServiceProvider;
use Orchestra\Testbench\TestCase;

// TODO: Care for Testbench
class CompilesIconsTest extends TestCase
class CompilesIconsTest extends \Orchestra\Testbench\TestCase
{
/** @test */
public function it_compiles_a_single_anonymous_component()
{
$result = svg('heroicon-o-bell')->toHtml();
$result = svg('flag')->toHtml();

// Note: the empty class here seems to be a Blade components bug.
$expected = <<<'SVG'
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
$expected =
'<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"/>
</svg>
SVG;
</svg>';

$this->assertSame($expected, $result);
$this->assertEquals($expected, $result);
}

/** @test */
public function it_can_add_classes_to_icons()
{
$result = svg('heroicon-o-bell', 'w-6 h-6 text-gray-500')->toHtml();
$result = svg('flag', 'w-6 h-6 text-gray-500')->toHtml();

$expected = <<<'SVG'
<svg class="w-6 h-6 text-gray-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
$expected =
'<svg class="w-6 h-6 text-gray-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"/>
</svg>
SVG;
</svg>';

$this->assertSame($expected, $result);
$this->assertEquals($expected, $result);
}

/** @test */
public function it_can_add_styles_to_icons()
{
$result = svg('heroicon-o-bell', ['style' => 'color: #555'])->toHtml();
$result = svg('flag', ['style' => 'color: #555'])->toHtml();

$expected = <<<'SVG'
<svg style="color: #555" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
$expected =
'<svg style="color: #555" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"/>
</svg>
SVG;
</svg>';

$this->assertSame($expected, $result);
$this->assertEquals($expected, $result);
}

protected function getPackageProviders($app)
{
return [
FlagsServiceProvider::class,
BladeIconsServiceProvider::class,
BladeHeroiconsServiceProvider::class,
];
}
}
Empty file.
44 changes: 44 additions & 0 deletions packages/flags/workbench/app/Models/User.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace Workbench\App\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
use HasFactory, Notifiable;

/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
];

/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];

/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Workbench\App\Providers;

use Illuminate\Support\ServiceProvider;

class WorkbenchServiceProvider extends ServiceProvider
{
/**
* Register services.
*/
public function register(): void
{
//
}

/**
* Bootstrap services.
*/
public function boot(): void
{
//
}
}
Empty file.
Empty file.
54 changes: 54 additions & 0 deletions packages/flags/workbench/database/factories/UserFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace Workbench\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Workbench\App\Models\User;

/**
* @template TModel of \Workbench\App\Models\User
*
* @extends \Illuminate\Database\Eloquent\Factories\Factory<TModel>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;

/**
* The name of the factory's corresponding model.
*
* @var class-string<TModel>
*/
protected $model = User::class;

/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];
}

/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}
Empty file.
23 changes: 23 additions & 0 deletions packages/flags/workbench/database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Workbench\Database\Seeders;

use Illuminate\Database\Seeder;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Workbench\Database\Factories\UserFactory;

class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*/
public function run(): void
{
// UserFactory::new(10)->create();

UserFactory::new()->create([
'name' => 'Test User',
'email' => '[email protected]',
]);
}
}
Empty file.
7 changes: 7 additions & 0 deletions packages/flags/workbench/routes/web.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

use Illuminate\Support\Facades\Route;

Route::get('/', function () {
return view('welcome');
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
use Moox\Locate\Models\Area;
use Moox\Locate\Resources\AreaResource;
use Moox\Locate\Resources\LocateResource\Widgets\LocateWidgets;

class ListPage extends ListRecords
{
Expand All @@ -33,7 +31,7 @@ protected function getHeaderActions(): array
{
return [
CreateAction::make()
->using(function (array $data, string $model): Area {
->using(function (array $data, string $model): static {
return $model::create($data);
}),
];
Expand Down
28 changes: 12 additions & 16 deletions packages/press/src/Models/WpBasePost.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
use Awobaz\Mutator\Mutable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Str;

/**
* @property int $ID
* @property string $post_title
* @property string $post_name
* @property string $post_author
* @property WpPostMeta $postMeta
*/
class WpBasePost extends Model
{
Expand Down Expand Up @@ -64,8 +66,8 @@ public function __construct(array $attributes = [])
parent::__construct($attributes);

$this->wpPrefix = config('press.wordpress_prefix');
$this->table = $this->wpPrefix.'posts';
$this->metatable = $this->wpPrefix.'postmeta';
$this->table = $this->wpPrefix . 'posts';
$this->metatable = $this->wpPrefix . 'postmeta';

$this->appends = [
'verantwortlicher',
Expand Down Expand Up @@ -178,41 +180,35 @@ protected function isMetaField($key)
* Relations
*
*/
public function postMeta()
public function postMeta(): HasMany
{
return $this->hasMany(WpPostMeta::class, 'post_id', 'ID');
}

public function author()
public function author(): BelongsTo
{
return $this->belongsTo(WpUser::class, 'post_author', 'ID');
}

public function taxonomies()
public function taxonomies(): BelongsToMany
{
return $this->belongsToMany(WpTermTaxonomy::class, config('press.wordpress_prefix').'term_relationships', 'object_id', 'term_taxonomy_id');
return $this->belongsToMany(WpTermTaxonomy::class, config('press.wordpress_prefix') . 'term_relationships', 'object_id', 'term_taxonomy_id');
}

public function categories()
public function categories(): BelongsToMany
{
return $this->taxonomies()->where('taxonomy', 'category');
}

public function tags()
public function tags(): BelongsToMany
{
return $this->taxonomies()->where('taxonomy', 'post_tag');
}

public function comment()
public function comment(): HasMany
{
return $this->hasMany(WpComment::class, 'comment_post_ID');
}

public function meta()
{
return $this->hasMany(WpPostMeta::class, 'post_id', 'ID');
}

/*
* ACF- Fields Getter and Setter
*/
Expand Down
Loading

0 comments on commit a99b5c5

Please sign in to comment.