Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kuma-guy/ray.fakemodule
This package is deprecated. Please use Ray.TestDouble instead.
https://github.com/kuma-guy/ray.fakemodule
Last synced: 8 days ago
JSON representation
This package is deprecated. Please use Ray.TestDouble instead.
- Host: GitHub
- URL: https://github.com/kuma-guy/ray.fakemodule
- Owner: kuma-guy
- License: bsd-3-clause
- Created: 2015-04-20T13:07:01.000Z (over 9 years ago)
- Default Branch: 1.x
- Last Pushed: 2017-08-22T13:31:54.000Z (over 7 years ago)
- Last Synced: 2024-11-28T04:12:35.971Z (29 days ago)
- Language: PHP
- Homepage: https://github.com/ray-di/Ray.TestDouble
- Size: 37.1 KB
- Stars: 2
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ray.FakeModule
**This package is deprecated. Please use [Ray.TestDouble](https://github.com/ray-di/Ray.TestDouble) instead.**
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/shingo-kumagai/Ray.FakeModule/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/shingo-kumagai/Ray.FakeModule/?branch=master) [![Build Status](https://travis-ci.org/kuma-guy/Ray.FakeModule.svg?branch=1.x)](https://travis-ci.org/kuma-guy/Ray.FakeModule)
## Installation
### Composer install
$ composer require ray/fake-module
### Module install```php
use Ray\Di\AbstractModule;
use Ray\FakeModule\FakeModule;class AppModule extends AbstractModule
{
protected function configure()
{
$this->install(new FakeModule);
}
}
```
### Usage### Fake a resource uri.
`@FakeResource` annotation fake uri for building mock feature.
Annotate target resource, which you want to fake, with `@FakeResource` annotation. Then, 'Fake' prefixed resource in same namespace will be called via interceptor when original resource method called.*this feature heavily depends on BEAR.Resource [https://github.com/bearsunday/BEAR.Resource]*
Real resource
```php
namespace FakeVendor\Sandbox\Resource\App;use BEAR\Resource\ResourceObject;
use Ray\FakeModule\Annotation\FakeResource;/**
* @FakeResource
*/
class User extends ResourceObject
{
public function onGet($id)
{
// ...
}
}
```Fake resource
```php
namespace FakeVendor\Sandbox\Resource\App;use BEAR\Resource\ResourceObject;
class FakeUser extends ResourceObject
{
public function onGet($id)
{
// ...
}
}
```### Fake a class method.
`@FakeClass` annotation work as same as `@FakeResource`.
Real class.
```php
namespace FakeVendor\Sandbox\Module;use Ray\FakeModule\Annotation\FakeClass;
/**
* @FakeClass
*/
class TestClass
{
public function output() {
return "test class output";
}
}
```Fake class.
```php
namespace FakeVendor\Sandbox\Module;class FakeTestClass
{
public function output() {
return "fake class output";
}
}
```### Requirements
* PHP 5.5+
* hhvm