Skip to content

Commit

Permalink
Soap is now macroable.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeraymonddowning committed Dec 8, 2020
1 parent e049ad3 commit c4e7fc4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Soap.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
namespace RicorocksDigitalAgency\Soap;

use Illuminate\Support\Traits\ForwardsCalls;
use Illuminate\Support\Traits\Macroable;
use RicorocksDigitalAgency\Soap\Parameters\Node;
use RicorocksDigitalAgency\Soap\Request\Request;
use RicorocksDigitalAgency\Soap\Support\Fakery\Fakery;

class Soap
{
use ForwardsCalls;
use Macroable {
__call as __macroableCall;
}

protected Fakery $fakery;
protected $inclusions = [];
Expand Down Expand Up @@ -67,6 +71,10 @@ public function afterRequesting(callable $hook)

public function __call($method, $parameters)
{
if (static::hasMacro($method)) {
return $this->__macroableCall($method, $parameters);
}

return $this->forwardCallTo($this->fakery, $method, $parameters);
}
}
27 changes: 27 additions & 0 deletions tests/MacroableTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php


namespace RicorocksDigitalAgency\Soap\Tests;


use Exception;
use RicorocksDigitalAgency\Soap\Facades\Soap;

class MacroableTest extends TestCase
{

/** @test */
public function soap_is_macroable()
{
$this->expectExceptionObject(new Exception("You sucessfully called this!"));

Soap::macro('test', function() {
throw new Exception("You sucessfully called this!");
});

Soap::test();

$this->fail("An exception should have been thrown!");
}

}

0 comments on commit c4e7fc4

Please sign in to comment.