diff --git a/database/seeders/AltumCodeVendorSeeder.php b/database/seeders/AltumCodeVendorSeeder.php new file mode 100644 index 0000000..0e63f75 --- /dev/null +++ b/database/seeders/AltumCodeVendorSeeder.php @@ -0,0 +1,211 @@ +products() as $product) { + Vendor::updateOrCreate( + ['slug' => $product['slug']], + $product, + ); + } + + foreach ($this->plugins() as $plugin) { + Vendor::updateOrCreate( + ['slug' => $plugin['slug']], + $plugin, + ); + } + } + + /** + * AltumCode licensed products. + * + * @return array> + */ + protected function products(): array + { + return [ + [ + 'slug' => '66analytics', + 'name' => '66analytics', + 'vendor_name' => 'AltumCode', + 'source_type' => Vendor::SOURCE_LICENSED, + 'plugin_platform' => Vendor::PLATFORM_ALTUM, + 'current_version' => '0.0.0', + 'is_active' => true, + ], + [ + 'slug' => '66biolinks', + 'name' => '66biolinks', + 'vendor_name' => 'AltumCode', + 'source_type' => Vendor::SOURCE_LICENSED, + 'plugin_platform' => Vendor::PLATFORM_ALTUM, + 'current_version' => '0.0.0', + 'is_active' => true, + ], + [ + 'slug' => '66pusher', + 'name' => '66pusher', + 'vendor_name' => 'AltumCode', + 'source_type' => Vendor::SOURCE_LICENSED, + 'plugin_platform' => Vendor::PLATFORM_ALTUM, + 'current_version' => '0.0.0', + 'is_active' => true, + ], + [ + 'slug' => '66socialproof', + 'name' => '66socialproof', + 'vendor_name' => 'AltumCode', + 'source_type' => Vendor::SOURCE_LICENSED, + 'plugin_platform' => Vendor::PLATFORM_ALTUM, + 'current_version' => '0.0.0', + 'is_active' => true, + ], + ]; + } + + /** + * AltumCode plugins. + * + * @return array> + */ + protected function plugins(): array + { + return [ + [ + 'slug' => 'altum-plugin-affiliate', + 'name' => 'Affiliate Plugin', + 'vendor_name' => 'AltumCode', + 'source_type' => Vendor::SOURCE_PLUGIN, + 'plugin_platform' => Vendor::PLATFORM_ALTUM, + 'current_version' => '0.0.0', + 'is_active' => true, + ], + [ + 'slug' => 'altum-plugin-push-notifications', + 'name' => 'Push Notifications Plugin', + 'vendor_name' => 'AltumCode', + 'source_type' => Vendor::SOURCE_PLUGIN, + 'plugin_platform' => Vendor::PLATFORM_ALTUM, + 'current_version' => '0.0.0', + 'is_active' => true, + ], + [ + 'slug' => 'altum-plugin-teams', + 'name' => 'Teams Plugin', + 'vendor_name' => 'AltumCode', + 'source_type' => Vendor::SOURCE_PLUGIN, + 'plugin_platform' => Vendor::PLATFORM_ALTUM, + 'current_version' => '0.0.0', + 'is_active' => true, + ], + [ + 'slug' => 'altum-plugin-pwa', + 'name' => 'PWA Plugin', + 'vendor_name' => 'AltumCode', + 'source_type' => Vendor::SOURCE_PLUGIN, + 'plugin_platform' => Vendor::PLATFORM_ALTUM, + 'current_version' => '0.0.0', + 'is_active' => true, + ], + [ + 'slug' => 'altum-plugin-image-optimizer', + 'name' => 'Image Optimizer Plugin', + 'vendor_name' => 'AltumCode', + 'source_type' => Vendor::SOURCE_PLUGIN, + 'plugin_platform' => Vendor::PLATFORM_ALTUM, + 'current_version' => '0.0.0', + 'is_active' => true, + ], + [ + 'slug' => 'altum-plugin-email-shield', + 'name' => 'Email Shield Plugin', + 'vendor_name' => 'AltumCode', + 'source_type' => Vendor::SOURCE_PLUGIN, + 'plugin_platform' => Vendor::PLATFORM_ALTUM, + 'current_version' => '0.0.0', + 'is_active' => true, + ], + [ + 'slug' => 'altum-plugin-dynamic-og-images', + 'name' => 'Dynamic OG Images Plugin', + 'vendor_name' => 'AltumCode', + 'source_type' => Vendor::SOURCE_PLUGIN, + 'plugin_platform' => Vendor::PLATFORM_ALTUM, + 'current_version' => '0.0.0', + 'is_active' => true, + ], + [ + 'slug' => 'altum-plugin-offload', + 'name' => 'Offload & CDN Plugin', + 'vendor_name' => 'AltumCode', + 'source_type' => Vendor::SOURCE_PLUGIN, + 'plugin_platform' => Vendor::PLATFORM_ALTUM, + 'current_version' => '0.0.0', + 'is_active' => true, + ], + [ + 'slug' => 'altum-plugin-payment-blocks', + 'name' => 'Payment Blocks Plugin', + 'vendor_name' => 'AltumCode', + 'source_type' => Vendor::SOURCE_PLUGIN, + 'plugin_platform' => Vendor::PLATFORM_ALTUM, + 'current_version' => '0.0.0', + 'is_active' => true, + ], + [ + 'slug' => 'altum-plugin-ultimate-blocks', + 'name' => 'Ultimate Blocks Plugin', + 'vendor_name' => 'AltumCode', + 'source_type' => Vendor::SOURCE_PLUGIN, + 'plugin_platform' => Vendor::PLATFORM_ALTUM, + 'current_version' => '0.0.0', + 'is_active' => true, + ], + [ + 'slug' => 'altum-plugin-pro-blocks', + 'name' => 'Pro Blocks Plugin', + 'vendor_name' => 'AltumCode', + 'source_type' => Vendor::SOURCE_PLUGIN, + 'plugin_platform' => Vendor::PLATFORM_ALTUM, + 'current_version' => '0.0.0', + 'is_active' => true, + ], + [ + 'slug' => 'altum-plugin-pro-notifications', + 'name' => 'Pro Notifications Plugin', + 'vendor_name' => 'AltumCode', + 'source_type' => Vendor::SOURCE_PLUGIN, + 'plugin_platform' => Vendor::PLATFORM_ALTUM, + 'current_version' => '0.0.0', + 'is_active' => true, + ], + [ + 'slug' => 'altum-plugin-aix', + 'name' => 'AIX Plugin', + 'vendor_name' => 'AltumCode', + 'source_type' => Vendor::SOURCE_PLUGIN, + 'plugin_platform' => Vendor::PLATFORM_ALTUM, + 'current_version' => '0.0.0', + 'is_active' => true, + ], + ]; + } +} diff --git a/tests/Pest.php b/tests/Pest.php index 7f6d8cf..bb36909 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -2,6 +2,6 @@ declare(strict_types=1); -use Orchestra\Testbench\TestCase; +use Tests\TestCase; uses(TestCase::class)->in('Feature', 'Unit'); diff --git a/tests/Unit/AltumCodeVendorSeederTest.php b/tests/Unit/AltumCodeVendorSeederTest.php new file mode 100644 index 0000000..da1f9e9 --- /dev/null +++ b/tests/Unit/AltumCodeVendorSeederTest.php @@ -0,0 +1,60 @@ +run(); + + $products = Vendor::where('source_type', Vendor::SOURCE_LICENSED) + ->where('plugin_platform', Vendor::PLATFORM_ALTUM) + ->get(); + + expect($products)->toHaveCount(4) + ->and($products->pluck('slug')->sort()->values()->all())->toBe([ + '66analytics', + '66biolinks', + '66pusher', + '66socialproof', + ]); + + $products->each(function (Vendor $vendor) { + expect($vendor->vendor_name)->toBe('AltumCode') + ->and($vendor->is_active)->toBeTrue() + ->and($vendor->current_version)->toBe('0.0.0'); + }); +}); + +it('seeds 13 altum plugins', function () { + $seeder = new AltumCodeVendorSeeder; + $seeder->run(); + + $plugins = Vendor::where('source_type', Vendor::SOURCE_PLUGIN) + ->where('plugin_platform', Vendor::PLATFORM_ALTUM) + ->get(); + + expect($plugins)->toHaveCount(13); + + $plugins->each(function (Vendor $vendor) { + expect($vendor->vendor_name)->toBe('AltumCode') + ->and($vendor->is_active)->toBeTrue() + ->and($vendor->current_version)->toBe('0.0.0') + ->and($vendor->slug)->toStartWith('altum-plugin-'); + }); +}); + +it('is idempotent — running twice still yields 17 total', function () { + $seeder = new AltumCodeVendorSeeder; + + $seeder->run(); + expect(Vendor::count())->toBe(17); + + $seeder->run(); + expect(Vendor::count())->toBe(17); +});