Skip to content
Merged
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
22 changes: 21 additions & 1 deletion src/CallableResolver/Exception/CouldNotResolveCallable.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@ public static function createFor($value)

private static function printValue($value)
{
return str_replace(' ', '', str_replace("\n", '', print_r($value, true)));
return str_replace(' ', '', str_replace("\n", '', print_r(self::convertValue($value), true)));
}

private static function convertValue($value)
{
if (is_array($value)) {
return array_map(function($value){
return self::convertObject($value);
}, $value);
}

return self::convertObject($value);
}

private static function convertObject($value)
{
if (is_object($value)) {
return get_class($value);
}

return $value;
}
}
38 changes: 36 additions & 2 deletions tests/CallableResolver/ServiceLocatorAwareCallableResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,24 @@ public function it_fails_if_the_loaded_service_is_not_callable()

$this->setExpectedException(
'SimpleBus\Message\CallableResolver\Exception\CouldNotResolveCallable',
'stdClass Object() could not be resolved to a valid callable'
'stdClass could not be resolved to a valid callable'
);
$this->resolver->resolve('not_a_callable');
}

/**
* @test
*/
public function it_fails_if_the_loaded_service_is_not_callable_does_not_list_child_service()
{
$handler = new \stdClass();
$handler->childService = new \stdClass();

$this->services['not_a_callable'] = $handler;

$this->setExpectedException(
'SimpleBus\Message\CallableResolver\Exception\CouldNotResolveCallable',
'stdClass could not be resolved to a valid callable'
);
$this->resolver->resolve('not_a_callable');
}
Expand All @@ -93,7 +110,24 @@ public function it_fails_if_the_loaded_service_and_method_array_is_not_callable(

$this->setExpectedException(
'SimpleBus\Message\CallableResolver\Exception\CouldNotResolveCallable',
'Array([0] => stdClass Object()[1] => nonExistingMethod) could not be resolved to a valid callable'
'Array([0] => stdClass[1] => nonExistingMethod) could not be resolved to a valid callable'
);
$this->resolver->resolve(['callable_service_id', 'nonExistingMethod']);
}

/**
* @test
*/
public function it_fails_if_the_loaded_service_and_method_array_is_not_callable_does_not_list_child_service()
{
$handler = new \stdClass();
$handler->childService = new \stdClass();

$this->services['callable_service_id'] = $handler;

$this->setExpectedException(
'SimpleBus\Message\CallableResolver\Exception\CouldNotResolveCallable',
'Array([0] => stdClass[1] => nonExistingMethod) could not be resolved to a valid callable'
);
$this->resolver->resolve(['callable_service_id', 'nonExistingMethod']);
}
Expand Down