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

🐛 Fix issue https://github.com/Rareloop/lumberjack/issues/26 #29

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "rareloop/lumberjack-core",
"name": "androlax2/lumberjack-core",
"description": "A powerful MVC framework for the modern WordPress developer. Write better, more expressive and easier to maintain code",
"license": "MIT",
"require": {
Expand All @@ -16,7 +16,6 @@
"symfony/debug": "^4.1",
"tightenco/collect": "^5.6.0",
"statamic/stringy": "~3.1.0",
"laminas/laminas-diactoros": "^2.4",
"rareloop/psr7-server-request-extension": "^2.1.0",
"mmeyer2k/dcrypt": "^8.0.1",
"spatie/macroable": "^1.0",
Expand Down
10 changes: 6 additions & 4 deletions src/Providers/CustomPostTypesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ class CustomPostTypesServiceProvider extends ServiceProvider
{
public function boot(Config $config)
{
$postTypesToRegister = $config->get('posttypes.register');
add_action('init', function () use ($config) {
$postTypesToRegister = $config->get('posttypes.register');

foreach ($postTypesToRegister as $postType) {
$postType::register();
}
foreach ($postTypesToRegister as $postType) {
$postType::register();
}
});
}
}
6 changes: 6 additions & 0 deletions tests/Unit/Providers/CustomPostTypesServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
namespace Rareloop\Lumberjack\Test;

use Brain\Monkey\Functions;
use Brain\Monkey\Actions;
use Mockery;
use PHPUnit\Framework\TestCase;
use Rareloop\Lumberjack\Application;
use Rareloop\Lumberjack\Config;
use Rareloop\Lumberjack\Post;
use Rareloop\Lumberjack\Providers\CustomPostTypesServiceProvider;
use Rareloop\Lumberjack\Providers\ServiceProvider;
use Rareloop\Lumberjack\Test\Unit\BrainMonkeyPHPUnitIntegration;

class CustomPostTypesServiceProviderTest extends TestCase
Expand All @@ -30,6 +32,10 @@ public function should_call_register_post_type_for_each_configured_post_type()
Functions\expect('register_post_type')
->times(2);

Actions\expectAdded('init')
->once()
->whenHappen(fn ($callback) => $callback());

$provider = new CustomPostTypesServiceProvider($app);
$provider->boot($config);
}
Expand Down