Skip to content
Snippets Groups Projects
Verified Commit f1cd022a authored by Bartek Jaskulski's avatar Bartek Jaskulski
Browse files

test: update binding loader test

parent 5dfee549
No related branches found
No related tags found
2 merge requests!3improve into wp-hook and some additional unfinished things,!21.x
This commit is part of merge request !2. Comments created here will be created in the context of that merge request.
......@@ -3,31 +3,43 @@ declare( strict_types=1 );
namespace WPDesk\Init\Tests\Binding;
use WPDesk\Init\Binding\Loader\ArrayBindingLoader;
use WPDesk\Init\Binding\Definition\UnknownDefinition;
use WPDesk\Init\Binding\Loader\DirectoryBasedLoader;
use WPDesk\Init\Configuration\Configuration;
use WPDesk\Init\Loader\PhpFileLoader;
use WPDesk\Init\Tests\TestCase;
class DirectoryBasedLoaderTest extends TestCase {
public function test_throws_when_configuration_entry_is_missing(): void {
public function xtest_throws_when_configuration_entry_is_missing(): void {
$this->expectException(\InvalidArgumentException::class);
$a = new DirectoryBasedLoader(new Configuration([]), new PhpFileLoader());
$a = new DirectoryBasedLoader(new Configuration([]));
$a->load();
}
public function test_loading_empty_bindings(): void {
$this->initTempPlugin('hook-bindings');
$a = new DirectoryBasedLoader(new Configuration(['hook_resources_path' => './']), new PhpFileLoader());
$actual = [];
foreach ($a->load() as $k => $v) {
$actual[$k] = array_merge( $actual[$k] ?? [], (array) $v );
$a = new DirectoryBasedLoader('./');
$actual = iterator_to_array($a->load(), false);
$this->assertEquals(
[
new UnknownDefinition('binding', 'hook1'),
new UnknownDefinition('binding1', 'plugins_loaded'),
new UnknownDefinition('binding2', 'plugins_loaded'),
],
$actual
);
}
public function test_load_illogical_bindings(): void {
$this->initTempPlugin('borked-bindings');
$a = new DirectoryBasedLoader('./');
$actual = iterator_to_array($a->load(), false);
$this->assertEquals(
[
'hook1' => ['binding'],
'plugins_loaded' => ['binding1', 'binding2'],
new UnknownDefinition('binding', 'hook1'),
new UnknownDefinition('binding1', 'plugins_loaded'),
new UnknownDefinition('binding2', 'plugins_loaded'),
],
$actual
);
......
<?php
return [
'hook1' => 'binding',
];
<?php
return [
'hook1' => 'binding1',
'binding2',
];
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment