Skip to content

Commit 95b1325

Browse files
author
Adam Benson
committed
Renamed TestInjector to MockInjector as more appropriate.
1 parent 6724b2d commit 95b1325

6 files changed

Lines changed: 27 additions & 27 deletions

File tree

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "bigcommerce/test-injector",
2+
"name": "bigcommerce/mock-injector",
33
"type": "library",
44
"description": "Auto-mocking injector for testing DI components",
55
"keywords": [
@@ -19,7 +19,7 @@
1919
"repositories": [
2020
{
2121
"type": "vcs",
22-
"url": "ssh://git@github.com/bigcommerce-labs/pimple-injector.git"
22+
"url": "ssh://git@github.com/bigcommerce-labs/injector.git"
2323
}
2424
],
2525
"require": {
@@ -29,7 +29,7 @@
2929
},
3030
"autoload": {
3131
"psr-4": {
32-
"Bigcommerce\\TestInjector\\": "src/"
32+
"Bigcommerce\\MockInjector\\": "src/"
3333
}
3434
},
3535
"autoload-dev": {

composer.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/AutoMockingTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace Bigcommerce\TestInjector;
2+
namespace Bigcommerce\MockInjector;
33

44
use Bigcommerce\Injector\InjectorInterface;
55

@@ -11,7 +11,7 @@
1111
*/
1212
abstract class AutoMockingTest extends \PHPUnit_Framework_TestCase
1313
{
14-
/** @var InjectorInterface|TestInjector */
14+
/** @var InjectorInterface|MockInjector */
1515
protected $injector;
1616

1717
/**
@@ -21,7 +21,7 @@ abstract class AutoMockingTest extends \PHPUnit_Framework_TestCase
2121
protected function setUp()
2222
{
2323
parent::setUp();
24-
$this->injector = new TestInjector();
24+
$this->injector = new MockInjector();
2525
}
2626

2727
/**
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace Bigcommerce\TestInjector;
2+
namespace Bigcommerce\MockInjector;
33

44
use Bigcommerce\Injector\Cache\ArrayServiceCache;
55
use Bigcommerce\Injector\Injector;
@@ -10,12 +10,12 @@
1010
use Prophecy\Prophet;
1111

1212
/**
13-
* The TestInjector is a specialised version of the injector that automatically mocks dependencies of objects being
13+
* The MockInjector is a specialised version of the injector that automatically mocks dependencies of objects being
1414
* tested using the same introspection of parameter types as the default Injector.
15-
* Note that any prophecy mock auto-generated by the TestInjector can be accessed via the ::getMock method.
15+
* Note that any prophecy mock auto-generated by the MockInjector can be accessed via the ::getMock method.
1616
* @package \Bigcommerce\Injector
1717
*/
18-
class TestInjector implements InjectorInterface
18+
class MockInjector implements InjectorInterface
1919
{
2020
/**
2121
* @var InjectorInterface
@@ -27,8 +27,8 @@ class TestInjector implements InjectorInterface
2727
private $mockingContainer;
2828

2929
/**
30-
* TestInjector constructor.
31-
* NOTE: The TestInjector intentionally does not use DependencyInjection and instantiates its own
30+
* MockInjector constructor.
31+
* NOTE: The MockInjector intentionally does not use DependencyInjection and instantiates its own
3232
* dependencies via poor mans DI as it is used only for testing purposes and is tightly coupled to
3333
* its dependencies.
3434
* @param MockingContainer $mockingContainer
@@ -119,4 +119,4 @@ public function invoke($instance, $methodName, $parameters = [])
119119
{
120120
return $this->injector->invoke($instance, $methodName, $parameters);
121121
}
122-
}
122+
}

src/MockingContainer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace Bigcommerce\TestInjector;
2+
namespace Bigcommerce\MockInjector;
33

44

55
use Interop\Container\ContainerInterface;
@@ -98,4 +98,4 @@ private function createOrGetMock($mockClassName)
9898
}
9999
return $this->mocks[$mockClassName];
100100
}
101-
}
101+
}

tests/TestInjectorTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
namespace Tests;
33

44
use Bigcommerce\Injector\InjectorInterface;
5-
use Bigcommerce\TestInjector\MockingContainer;
6-
use Bigcommerce\TestInjector\TestInjector;
5+
use Bigcommerce\MockInjector\MockingContainer;
6+
use Bigcommerce\MockInjector\MockInjector;
77
use Prophecy\Prophecy\ObjectProphecy;
88
use Tests\Dummy\DummyDependency;
99
use Tests\Dummy\DummySubDependency;
1010

1111
/**
1212
*
13-
* @coversDefaultClass \Bigcommerce\TestInjector\TestInjector
13+
* @coversDefaultClass \Bigcommerce\MockInjector\TestInjector
1414
*/
1515
class TestInjectorTest extends \PHPUnit_Framework_TestCase
1616
{
@@ -32,7 +32,7 @@ protected function setUp()
3232
public function testCreate()
3333
{
3434
$this->injector->create("abc123", [1 => "hello"])->willReturn("cat")->shouldBeCalledTimes(1);
35-
$i = new TestInjector($this->mockContainer->reveal(), $this->injector->reveal());
35+
$i = new MockInjector($this->mockContainer->reveal(), $this->injector->reveal());
3636
$this->assertEquals("cat", $i->create("abc123", [1 => "hello"]));
3737
}
3838

@@ -43,7 +43,7 @@ public function testInvoke()
4343
{
4444
$obj = new \stdClass();
4545
$this->injector->invoke($obj, "method1", [1 => "hello"])->willReturn("fish")->shouldBeCalledTimes(1);
46-
$i = new TestInjector($this->mockContainer->reveal(), $this->injector->reveal());
46+
$i = new MockInjector($this->mockContainer->reveal(), $this->injector->reveal());
4747
$this->assertEquals("fish", $i->invoke($obj, "method1", [1 => "hello"]));
4848
}
4949

@@ -53,7 +53,7 @@ public function testInvoke()
5353
public function testCheckPredictions()
5454
{
5555
$this->mockContainer->checkPredictions()->shouldBeCalledTimes(1);
56-
$i = new TestInjector($this->mockContainer->reveal(), $this->injector->reveal());
56+
$i = new MockInjector($this->mockContainer->reveal(), $this->injector->reveal());
5757
$i->checkPredictions();
5858
}
5959

@@ -63,7 +63,7 @@ public function testCheckPredictions()
6363
public function testGetAllMocks()
6464
{
6565
$this->mockContainer->getAllMocks()->willReturn([1, 2, 6])->shouldBeCalledTimes(1);
66-
$i = new TestInjector($this->mockContainer->reveal(), $this->injector->reveal());
66+
$i = new MockInjector($this->mockContainer->reveal(), $this->injector->reveal());
6767
$this->assertEquals([1, 2, 6], $i->getAllMocks());
6868
}
6969

@@ -74,7 +74,7 @@ public function testGetMock()
7474
{
7575
$dummy = new \stdClass();
7676
$this->mockContainer->getMock("blah")->willReturn($dummy)->shouldBeCalledTimes(1);
77-
$i = new TestInjector($this->mockContainer->reveal(), $this->injector->reveal());
77+
$i = new MockInjector($this->mockContainer->reveal(), $this->injector->reveal());
7878
$this->assertEquals($dummy, $i->getMock("blah"));
7979
}
8080

@@ -85,7 +85,7 @@ public function testGetMock()
8585
*/
8686
public function testWithoutDependencies()
8787
{
88-
$i = new TestInjector();
88+
$i = new MockInjector();
8989
/** @var DummyDependency $obj */
9090
$obj = $i->create(DummyDependency::class);
9191
$this->assertInstanceOf(DummySubDependency::class, $obj->getDependency());

0 commit comments

Comments
 (0)