-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alex Ermashev
committed
Aug 6, 2020
1 parent
282ac55
commit b1bdd71
Showing
2 changed files
with
65 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Tiny package. | ||
* | ||
* (c) Alex Ermashev <alexermashevn@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Tiny\ServiceManager\Factory; | ||
|
||
use Tiny\ServiceManager\ServiceManager; | ||
|
||
class InvokableFactory | ||
{ | ||
|
||
/** | ||
* @param ServiceManager $serviceManager | ||
* @param string $targetClass | ||
* | ||
* @return object | ||
*/ | ||
public function __invoke( | ||
ServiceManager $serviceManager, | ||
string $targetClass | ||
) { | ||
return new $targetClass(); | ||
} | ||
|
||
} |
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,33 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Tiny package. | ||
* | ||
* (c) Alex Ermashev <alexermashevn@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace TinyTest\ServiceManager\Factory; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Tiny\ServiceManager\Factory\InvokableFactory; | ||
use Tiny\ServiceManager\ServiceManager; | ||
use stdClass; | ||
|
||
class invokableFactoryTest extends TestCase | ||
{ | ||
|
||
public function testInvokeMethod() | ||
{ | ||
$factory = new InvokableFactory(); | ||
$instance = $factory( | ||
$this->createMock(ServiceManager::class), | ||
stdClass::class | ||
); | ||
|
||
$this->assertInstanceOf(stdClass::class, $instance); | ||
} | ||
|
||
} |