Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
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
21 changes: 21 additions & 0 deletions library/Zend/Soap/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ class Server implements ZendServerServer
*/
protected $object;

/**
* Informs if the soap server is in debug mode
* @var bool
*/
protected $debug = false;

/**
* Persistence mode; should be one of the SOAP persistence constants
* @var int
Expand Down Expand Up @@ -925,6 +931,17 @@ protected function _initializeSoapErrorContext()
return $displayErrorsOriginalState;
}

/**
* Set the debug mode.
* In debug mode, all exceptions are send to the client.
* @param bool $debug
*/
public function setDebugMode($debug)
{
$this->debug = $debug;
return $this;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setters in this class follows fluent interface so please, follow the same pattern,


/**
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a blank line between methods

* Validate and register fault exception
*
Expand Down Expand Up @@ -961,6 +978,10 @@ public function registerFaultException($class)
*/
public function isRegisteredAsFaultException($fault)
{
if ($this->debug) {
return true;
}

$ref = new ReflectionClass($fault);
$classNames = $ref->getName();
return in_array($classNames, $this->faultExceptions);
Expand Down
11 changes: 11 additions & 0 deletions tests/ZendTest/Soap/ServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -937,4 +937,15 @@ public function testShouldThrowExceptionIfHandledRequestContainsDoctype()
$this->assertContains('Invalid XML', $response->getMessage());
}

public function testDebugMode()
{
$server = new Server();
$beforeDebug = $server->fault(new \Exception('test'));
$server->setDebugMode(true);
$afterDebug = $server->fault(new \Exception('test'));

$this->assertEquals('Unknown error', $beforeDebug->getMessage());
$this->assertEquals('test', $afterDebug->getMessage());
}

}