✨ Add spy function
This commit is contained in:
parent
d857775289
commit
261c42dbab
4 changed files with 55 additions and 3 deletions
|
|
@ -37,7 +37,10 @@
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Danjones000\\Spy\\": "src/"
|
"Danjones000\\Spy\\": "src/"
|
||||||
}
|
},
|
||||||
|
"files": [
|
||||||
|
"src/functions.php"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|
|
||||||
33
src/functions.php
Normal file
33
src/functions.php
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file is part of danjones000/object-spy
|
||||||
|
*
|
||||||
|
* danjones000/object-spy is open source software: you can distribute
|
||||||
|
* it and/or modify it under the terms of the MIT License
|
||||||
|
* (the "License"). You may not use this file except in
|
||||||
|
* compliance with the License.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
* implied. See the License for the specific language governing
|
||||||
|
* permissions and limitations under the License.
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) Dan Jones <danjones@goodevilgenius.org>
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Danjones000\Spy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string|object $classOrObject
|
||||||
|
*
|
||||||
|
* @psalm-suppress RedundantConditionGivenDocblockType
|
||||||
|
*/
|
||||||
|
function spy($classOrObject): ObjectProxy
|
||||||
|
{
|
||||||
|
return new ObjectProxy($classOrObject);
|
||||||
|
}
|
||||||
18
tests/FunctionsTest.php
Normal file
18
tests/FunctionsTest.php
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Danjones000\Test\Spy;
|
||||||
|
|
||||||
|
use Danjones000\Spy\ObjectProxy;
|
||||||
|
|
||||||
|
use function Danjones000\Spy\spy;
|
||||||
|
|
||||||
|
class FunctionsTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testSpy(): void
|
||||||
|
{
|
||||||
|
$spy = spy(Fixtures\Example::class);
|
||||||
|
$this->assertInstanceOf(ObjectProxy::class, $spy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,8 +5,6 @@ declare(strict_types=1);
|
||||||
namespace Danjones000\Test\Spy;
|
namespace Danjones000\Test\Spy;
|
||||||
|
|
||||||
use Danjones000\Spy\ObjectProxy;
|
use Danjones000\Spy\ObjectProxy;
|
||||||
use Mockery;
|
|
||||||
use Mockery\MockInterface;
|
|
||||||
|
|
||||||
class ObjectProxyTest extends TestCase
|
class ObjectProxyTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue