-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX Don't swallow relevant BadMethodCallExceptions from ViewLayerData (…
- Loading branch information
1 parent
c651007
commit 89e8b36
Showing
5 changed files
with
113 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
tests/php/View/ViewLayerDataTest/TestBadMethodCallObject.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace SilverStripe\View\Tests\ViewLayerDataTest; | ||
|
||
use BadMethodCallException; | ||
use SilverStripe\Dev\TestOnly; | ||
|
||
class TestBadMethodCallObject implements TestOnly | ||
{ | ||
public function __call(string $name, array $arguments): void | ||
{ | ||
throw new BadMethodCallException('This exception should be caught by ViewLayerData'); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
tests/php/View/ViewLayerDataTest/TestBadMethodCallObjectSubclass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace SilverStripe\View\Tests\ViewLayerDataTest; | ||
|
||
use BadMethodCallException; | ||
use SilverStripe\Dev\TestOnly; | ||
use SilverStripe\Model\ModelData; | ||
|
||
class TestBadMethodCallObjectSubclass extends TestBadMethodCallObject implements TestOnly | ||
{ | ||
public function __call(string $name, array $arguments): void | ||
{ | ||
if ($name === 'directMethod') { | ||
throw new BadMethodCallException('This exception should be caught by ViewLayerData'); | ||
} | ||
if ($name === 'realMethod') { | ||
$this->throwException(); | ||
} | ||
if ($name === 'anotherClass') { | ||
$data = new ModelData(); | ||
$data->thisMethodDoesntExist(); | ||
} | ||
parent::__call($name, $arguments); | ||
} | ||
|
||
public function throwException(): void | ||
{ | ||
throw new BadMethodCallException('This exception should NOT be caught by ViewLayerData'); | ||
} | ||
} |