Skip to content

Commit

Permalink
Merge pull request #10 from Ricorocks-Digital-Agency/macroable_support
Browse files Browse the repository at this point in the history
Soap is now macroable
  • Loading branch information
lukeraymonddowning authored Dec 8, 2020
2 parents e049ad3 + c4e7fc4 commit 5ebe3b7
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 5ebe3b7

Please sign in to comment.