Skip to content

Commit fe058b3

Browse files
Merge pull request #2 from precariouspanther/rename-automock-helper
Renamed automock helper for automocking test to better reflect what t…
2 parents f690a0f + cedc936 commit fe058b3

6 files changed

Lines changed: 89 additions & 4 deletions

File tree

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#### What?
2+
3+
A description about what this pull request implements and its purpose. Try to be detailed and describe any technical
4+
details to simplify the job of the reviewer.
5+
6+
#### Tickets / Documentation
7+
8+
Add links to any relevant issues and documentation.
9+
10+
- [Link 1](http://example.com)
11+
- ...
12+

CONTRIBUTING.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Contributing to Mock Injector
2+
3+
Thanks for showing interest in contributing!
4+
5+
The following is a set of guidelines for contributing to the project. These are just guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
6+
7+
By contributing to this codebase, you agree that your contributions will be licensed under its MIT license.
8+
9+
### Pull Requests
10+
11+
* Fill in [the required template](https://github.com/bigcommerce-labs/mock-injector/pull/new/master)
12+
* End files with a newline.
13+
14+
## Styleguides
15+
16+
### Git Commit Messages
17+
18+
* Use the present tense ("Add feature" not "Added feature")
19+
* Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
20+
* Limit the first line to 72 characters or less
21+
* Reference pull requests and external links liberally
22+
23+
### PHP Styleguide
24+
25+
All PHP must adhere to PSR-1, 2 and 4 as specified by the [PHP-FIG](http://www.php-fig.org/psr/).

LICENSE.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
(The MIT License)
2+
Copyright (C) 2015-2017 BigCommerce Inc.
3+
All rights reserved.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7+
rights to use, copy, modify, merge, publish, distribute, sublicense,and/or sell copies of the Software, and to permit
8+
persons to whom the Software is furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11+
Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# bigcommerce/test-injector
1+
# bigcommerce/mock-injector
22

33
Auto-mocking test Dependency Injector component
44

@@ -39,4 +39,22 @@ $result = $testInjector->invoke($instanceOfThing, "createUser", [
3939
````
4040

4141

42-
For integration with your PHPUnit tests, see: [AutoMockingTest.php](src/AutoMockingTest.php)
42+
For integration with your PHPUnit tests, see: [AutoMockingTest.php](src/AutoMockingTest.php)
43+
44+
45+
(The MIT License)
46+
Copyright (C) 2015-2017 BigCommerce Inc.
47+
All rights reserved.
48+
49+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
50+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
51+
rights to use, copy, modify, merge, publish, distribute, sublicense,and/or sell copies of the Software, and to permit
52+
persons to whom the Software is furnished to do so, subject to the following conditions:
53+
54+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
55+
Software.
56+
57+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
58+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
59+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
60+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
bootstrap="vendor/autoload.php"
77
>
88
<testsuites>
9-
<testsuite name="Injector Test Suite">
9+
<testsuite name="MockInjector Test Suite">
1010
<directory>./tests</directory>
1111
</testsuite>
1212
</testsuites>

src/AutoMockingTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,22 @@ protected function setUp()
2929
* @param string $className The FQCN of the class we are creating
3030
* @param array $parameters Any parameters to pass to the constructor. Can be keyed by type, name or position.
3131
* @return object
32+
* @deprecated
33+
* @see createWithMocks()
3234
*/
33-
protected function autoMock($className, $parameters = []){
35+
protected function autoMock($className, $parameters = [])
36+
{
37+
return $this->injector->create($className, $parameters);
38+
}
39+
40+
/**
41+
* Create an instance of $className and automatically mock all its constructor dependencies.
42+
* @param string $className The FQCN of the class we are creating
43+
* @param array $parameters Any parameters to pass to the constructor. Can be keyed by type, name or position.
44+
* @return object
45+
*/
46+
protected function createWithMocks($className, $parameters = [])
47+
{
3448
return $this->injector->create($className, $parameters);
3549
}
3650

0 commit comments

Comments
 (0)