Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
joelambert committed Oct 25, 2023
1 parent 1eaef8a commit 15eb807
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 60 deletions.
43 changes: 21 additions & 22 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,34 @@
"php": ">=7.3||>=8.0",
"php-di/php-di": "^6.4.0",
"rareloop/router": "^6.0.2",
"psr/container": "^1.0",
"psr/http-message": "^1.0",
"psr/http-server-middleware": "^1.0",
"psr/container": "^1.1.2",
"psr/http-message": "^1.1",
"psr/http-server-middleware": "^1.0.2",
"blast/facades": "^1.0",
"timber/timber": "^1.21.0",
"monolog/monolog": "^2.0",
"timber/timber": "^1.23.0",
"monolog/monolog": "^2.9.1",
"http-interop/response-sender": "^1.0",
"symfony/debug": "^4.1",
"illuminate/collections": "^8.53.1||^9.0.0",
"symfony/debug": "^4.4.44",
"illuminate/collections": "^8.53.1||^9.52.16",
"statamic/stringy": "^3.1.3",
"laminas/laminas-diactoros": "^2.4",
"laminas/laminas-diactoros": "^2.25.2",
"rareloop/psr7-server-request-extension": "^2.1.0",
"mmeyer2k/dcrypt": "^8.0.1",
"spatie/macroable": "^1.0",
"mindplay/middleman": "^3.0.3",
"psr/log": "^1.1",
"laminas/laminas-zendframework-bridge": "^1.4",
"symfony/var-dumper": "^5.0||^6.0"
"mmeyer2k/dcrypt": "^8.3.1",
"spatie/macroable": "^1.0.1",
"mindplay/middleman": "^3.1.0",
"psr/log": "^1.1.4",
"laminas/laminas-zendframework-bridge": "^1.7",
"symfony/var-dumper": "^5.0||^6.3.6"
},
"require-dev": {
"phpunit/phpunit": "^9.5.21",
"php-coveralls/php-coveralls": "^2.0",
"mockery/mockery": "^1.5.0",
"brain/monkey": "~2.4.2",
"squizlabs/php_codesniffer": "^3.6.0",
"php-mock/php-mock": "^2.3.1",
"phpunit/phpunit": "^9.6.13",
"php-coveralls/php-coveralls": "^2.6",
"mockery/mockery": "^1.6.6",
"brain/monkey": "^2.6.1",
"squizlabs/php_codesniffer": "^3.7.2",
"php-mock/php-mock": "^2.4.1",
"mikey179/vfsstream": "1.6.11",
"antecedent/patchwork": "^2.1.21",
"dms/phpunit-arraysubset-asserts": "^0.3.0"
"dms/phpunit-arraysubset-asserts": "^0.3.1"
},
"autoload": {
"psr-4": {
Expand Down
11 changes: 9 additions & 2 deletions tests/Unit/PostQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Rareloop\Lumberjack\Post;
use Rareloop\Lumberjack\QueryBuilder;
use Rareloop\Lumberjack\ScopedQueryBuilder;
use Throwable;

class PostQueryBuilderTest extends TestCase
{
Expand Down Expand Up @@ -50,9 +51,15 @@ public function can_create_a_builder_from_static_functions()
*/
public function throw_error_on_missing_static_function()
{
$this->expectError();
$errorThrown = false;

Post::missingStaticFunction();
try {
Post::missingStaticFunction();
} catch (Throwable $e) {
$errorThrown = true;
}

$this->assertTrue($errorThrown);
}

private function assertQueryBuilder($function, $params, $postType)
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Providers/RouterServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function wp_loaded_action_is_bound()
$app->register($provider);
$lumberjack->bootstrap();

$this->assertTrue(has_action('wp_loaded', 'function ()'));
$this->assertNotFalse(has_action('wp_loaded', 'function ()'));
}

/** @test */
Expand Down
59 changes: 27 additions & 32 deletions tests/Unit/Providers/WordPressControllersServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ class WordPressControllersServiceProviderTest extends TestCase
/** @test */
public function template_include_filter_is_applied_on_boot()
{
$app = new Application(__DIR__.'/../');
$app = new Application(__DIR__ . '/../');
$provider = new WordPressControllersServiceProvider($app);

$app->register($provider);
$app->boot();

$this->assertTrue(has_filter('template_include', [$provider, 'handleTemplateInclude']));
$this->assertNotFalse(has_filter('template_include', [$provider, 'handleTemplateInclude']));
}

/** @test */
public function handle_template_include_method_includes_the_requested_file()
{
$app = new Application(__DIR__.'/../');
$app = new Application(__DIR__ . '/../');

$this->assertNotContains(__DIR__ . '/includes/single.php', get_included_files());

Expand All @@ -57,7 +57,7 @@ public function handle_template_include_method_includes_the_requested_file()
/** @test */
public function handle_template_include_method_sets_details_in_container_when_controller_is_not_present()
{
$app = new Application(__DIR__.'/../');
$app = new Application(__DIR__ . '/../');

$provider = new WordPressControllersServiceProvider($app);
$provider->handleTemplateInclude(__DIR__ . '/includes/single.php');
Expand All @@ -72,10 +72,10 @@ public function handle_template_include_method_sets_details_in_container_when_co
public function handle_template_include_method_does_not_set_details_in_container_when_controller_is_present()
{
$response = new TextResponse('Testing 123', 200);
$app = Mockery::mock(Application::class.'[shutdown]', [__DIR__.'/..']);
$app = Mockery::mock(Application::class . '[shutdown]', [__DIR__ . '/..']);
$app->shouldReceive('shutdown')->times(1);

$provider = Mockery::mock(WordPressControllersServiceProvider::class.'[handleRequest]', [$app]);
$provider = Mockery::mock(WordPressControllersServiceProvider::class . '[handleRequest]', [$app]);
$provider->shouldReceive('handleRequest')->once()->andReturn($response);
$provider->boot($app);

Expand All @@ -88,7 +88,7 @@ public function handle_template_include_method_does_not_set_details_in_container
/** @test */
public function can_get_name_of_controller_from_template()
{
$app = new Application(__DIR__.'/../');
$app = new Application(__DIR__ . '/../');
$provider = new WordPressControllersServiceProvider($app);

$mappings = [
Expand All @@ -105,7 +105,7 @@ public function can_get_name_of_controller_from_template()
/** @test */
public function can_get_special_case_name_of_404_controller_from_template()
{
$app = new Application(__DIR__.'/../');
$app = new Application(__DIR__ . '/../');
$provider = new WordPressControllersServiceProvider($app);

$this->assertSame('App\\Error404Controller', $provider->getControllerClassFromTemplate(__DIR__ . 'includes/404.php'));
Expand All @@ -114,7 +114,7 @@ public function can_get_special_case_name_of_404_controller_from_template()
/** @test */
public function handle_template_include_applies_filters_on_controller_name_and_namespace()
{
$app = new Application(__DIR__.'/../');
$app = new Application(__DIR__ . '/../');
$provider = new WordPressControllersServiceProvider($app);

Filters\expectApplied('lumberjack_controller_name')
Expand All @@ -131,7 +131,7 @@ public function handle_template_include_applies_filters_on_controller_name_and_n
/** @test */
public function handle_request_returns_false_if_controller_does_not_exist()
{
$app = new Application(__DIR__.'/../');
$app = new Application(__DIR__ . '/../');
$provider = new WordPressControllersServiceProvider($app);

$response = $provider->handleRequest(new ServerRequest, 'Does\\Not\\Exist', 'handle');
Expand All @@ -145,7 +145,7 @@ public function handle_request_writes_warning_to_logs_if_controller_does_not_exi
$log = Mockery::mock(Logger::class);
$log->shouldReceive('warning')->once()->with('Controller class `Does\Not\Exist` not found');

$app = new Application(__DIR__.'/../');
$app = new Application(__DIR__ . '/../');
$app->bind('logger', $log);
$provider = new WordPressControllersServiceProvider($app);
$provider->boot();
Expand All @@ -156,7 +156,7 @@ public function handle_request_writes_warning_to_logs_if_controller_does_not_exi
/** @test */
public function handle_request_will_mark_request_handled_in_app_if_controller_does_exist()
{
$app = new Application(__DIR__.'/../');
$app = new Application(__DIR__ . '/../');

$provider = new WordPressControllersServiceProvider($app);
$provider->boot();
Expand All @@ -169,7 +169,7 @@ public function handle_request_will_mark_request_handled_in_app_if_controller_do
/** @test */
public function handle_request_will_not_mark_request_handled_in_app_if_controller_does_not_exist()
{
$app = new Application(__DIR__.'/../');
$app = new Application(__DIR__ . '/../');

$provider = new WordPressControllersServiceProvider($app);
$provider->boot();
Expand All @@ -182,7 +182,7 @@ public function handle_request_will_not_mark_request_handled_in_app_if_controlle
/** @test */
public function handle_request_returns_response_when_controller_does_exist()
{
$app = new Application(__DIR__.'/../');
$app = new Application(__DIR__ . '/../');

$provider = new WordPressControllersServiceProvider($app);
$provider->boot($app);
Expand All @@ -195,7 +195,7 @@ public function handle_request_returns_response_when_controller_does_exist()
/** @test */
public function handle_request_returns_response_when_controller_returns_a_responsable()
{
$app = new Application(__DIR__.'/../');
$app = new Application(__DIR__ . '/../');

$provider = new WordPressControllersServiceProvider($app);
$provider->boot($app);
Expand All @@ -209,7 +209,7 @@ public function handle_request_returns_response_when_controller_returns_a_respon
/** @test */
public function handle_request_resolves_constructor_params_from_container()
{
$app = new Application(__DIR__.'/../');
$app = new Application(__DIR__ . '/../');

$provider = new WordPressControllersServiceProvider($app);
$provider->boot($app);
Expand All @@ -222,7 +222,7 @@ public function handle_request_resolves_constructor_params_from_container()
/** @test */
public function handle_request_resolves_controller_method_params_from_container()
{
$app = new Application(__DIR__.'/../');
$app = new Application(__DIR__ . '/../');

$provider = new WordPressControllersServiceProvider($app);
$provider->boot($app);
Expand All @@ -235,7 +235,7 @@ public function handle_request_resolves_controller_method_params_from_container(
/** @test */
public function handle_request_supports_middleware()
{
$app = new Application(__DIR__.'/../');
$app = new Application(__DIR__ . '/../');
$controller = new TestControllerWithMiddleware;
$controller->middleware(new AddHeaderMiddleware('X-Header', 'testing123'));
$app->bind(TestControllerWithMiddleware::class, $controller);
Expand All @@ -252,7 +252,7 @@ public function handle_request_supports_middleware()
/** @test */
public function handle_request_supports_middleware_applied_to_a_specific_method_using_only()
{
$app = new Application(__DIR__.'/../');
$app = new Application(__DIR__ . '/../');
$controller = new TestControllerWithMiddleware;
$controller->middleware(new AddHeaderMiddleware('X-Header', 'testing123'))->only('notHandle');
$app->bind(TestControllerWithMiddleware::class, $controller);
Expand All @@ -268,7 +268,7 @@ public function handle_request_supports_middleware_applied_to_a_specific_method_
/** @test */
public function handle_request_supports_middleware_applied_to_a_specific_method_using_except()
{
$app = new Application(__DIR__.'/../');
$app = new Application(__DIR__ . '/../');
$controller = new TestControllerWithMiddleware;
$controller->middleware(new AddHeaderMiddleware('X-Header', 'testing123'))->except('handle');
$app->bind(TestControllerWithMiddleware::class, $controller);
Expand All @@ -290,7 +290,7 @@ public function handle_request_supports_middleware_aliases()
}
});

$app = new Application(__DIR__.'/../');
$app = new Application(__DIR__ . '/../');

$controller = new TestControllerWithMiddleware;
$controller->middleware('middleware-key');
Expand All @@ -315,10 +315,10 @@ public function handle_request_supports_middleware_aliases()
public function handle_template_include_will_call_app_shutdown_when_it_has_handled_a_request()
{
$response = new TextResponse('Testing 123', 404);
$app = Mockery::mock(Application::class.'[shutdown]', [__DIR__.'/..']);
$app = Mockery::mock(Application::class . '[shutdown]', [__DIR__ . '/..']);
$app->shouldReceive('shutdown')->times(1)->with($response);

$provider = Mockery::mock(WordPressControllersServiceProvider::class.'[handleRequest]', [$app]);
$provider = Mockery::mock(WordPressControllersServiceProvider::class . '[handleRequest]', [$app]);
$provider->shouldReceive('handleRequest')->once()->andReturn($response);
$provider->boot($app);

Expand All @@ -328,10 +328,10 @@ public function handle_template_include_will_call_app_shutdown_when_it_has_handl
/** @test */
public function handle_template_include_will_not_call_app_shutdown_when_it_has_not_handled_a_request()
{
$app = Mockery::mock(Application::class.'[shutdown]', [__DIR__.'/..']);
$app = Mockery::mock(Application::class . '[shutdown]', [__DIR__ . '/..']);
$app->shouldReceive('shutdown')->times(0);

$provider = Mockery::mock(WordPressControllersServiceProvider::class.'[handleRequest]', [$app]);
$provider = Mockery::mock(WordPressControllersServiceProvider::class . '[handleRequest]', [$app]);
$provider->shouldReceive('handleRequest')->once()->andReturn(false);
$provider->boot($app);

Expand All @@ -343,34 +343,30 @@ class TestController
{
public function handle()
{

}
}

class TestControllerWithConstructorParams
{
public function __construct(Application $app)
{

}

public function handle()
{

}
}

class TestControllerWithHandleParams
{
public function handle(Application $app)
{

}
}

class MyResponsable implements Responsable
{
public function toResponse(RequestInterface $request) : ResponseInterface
public function toResponse(RequestInterface $request): ResponseInterface
{
return new TextResponse('testing123');
}
Expand All @@ -388,7 +384,6 @@ class TestControllerWithMiddleware extends Controller
{
public function handle()
{

}
}

Expand All @@ -403,7 +398,7 @@ public function __construct($key, $value)
$this->value = $value;
}

public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$response = $handler->handle($request);

Expand Down
13 changes: 10 additions & 3 deletions tests/Unit/ScopedQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Rareloop\Lumberjack\Post;
use Rareloop\Lumberjack\QueryBuilder;
use Rareloop\Lumberjack\ScopedQueryBuilder;
use Throwable;
use Timber\Timber;

class ScopedQueryBuilderTest extends TestCase
Expand Down Expand Up @@ -114,10 +115,16 @@ public function can_pass_params_into_a_query_scope_on_post_object()
*/
public function missing_query_scope_throws_an_error()
{
$this->expectError();
$errorThrown = false;

$builder = new ScopedQueryBuilder(PostWithQueryScope::class);
$builder->nonExistentScope();
try {
$builder = new ScopedQueryBuilder(PostWithQueryScope::class);
$builder->nonExistentScope();
} catch (Throwable $e) {
$errorThrown = true;
}

$this->assertTrue($errorThrown);
}

/** @test */
Expand Down

0 comments on commit 15eb807

Please sign in to comment.