Skip to content

Commit

Permalink
Merge branch 'master' of github.com:navjobs/transmit
Browse files Browse the repository at this point in the history
  • Loading branch information
joshforbes committed Jun 30, 2016
2 parents 7b4fc08 + e54c86b commit 5a32937
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 364 deletions.
13 changes: 3 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[![Circle CI](https://circleci.com/gh/NavJobs/Transmit.svg?style=shield)](https://circleci.com/gh/NavJobs/Transmit)
[![Circle CI](https://circleci.com/gh/navjobs/transmit.svg?style=shield)](https://circleci.com/gh/navjobs/transmit)
[![Coverage Status](https://coveralls.io/repos/NavJobs/Transmit/badge.svg?branch=master&service=github)](https://coveralls.io/github/NavJobs/Transmit?branch=master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/NavJobs/Transmit/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/NavJobs/Transmit/?branch=master)
[![Latest Stable Version](https://poser.pugx.org/navjobs/transmit/v/stable)](https://packagist.org/packages/navjobs/transmit) [![Total Downloads](https://poser.pugx.org/navjobs/transmit/downloads)](https://packagist.org/packages/navjobs/transmit) [![License](https://poser.pugx.org/navjobs/transmit/license)](https://packagist.org/packages/navjobs/transmit)

###### Communication Layer For Laravel
Transmit was created to abstact the process of implementing external APIs and internal communications gateways across microservices.
Transmit was created to expedite the process of implementing REST APIs.

#### Install

Expand Down Expand Up @@ -252,21 +252,14 @@ Includes can also be sorted by query parameters, the URL format is:
http://www.example.com/books?include=authors:sort(name|-created_at),publisher
```

#### Gateway
Transmit provides an abstract gateway class that facilitates internal communication in a microservice architecture.

**Gateways are still a work in progress, and not recommended to be used in production yet**

Gateway Documentation coming soon.

## Fractal

Transmit is built on the back of two amazing PHP packages.

- [fractal](https://github.com/thephpleague/fractal)
- [laravel-fractal](https://github.com/spatie/laravel-fractal/tree/master/src).

Controllers and Gateways have an instance of laravel-fractal available through:
Controllers have an instance of laravel-fractal available through:

```php
$this->fractal;
Expand Down
23 changes: 0 additions & 23 deletions src/ForeignTransformer.php

This file was deleted.

135 changes: 0 additions & 135 deletions src/Gateway.php

This file was deleted.

46 changes: 43 additions & 3 deletions tests/Integration/ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,23 @@ public function it_can_respond_with_a_single_item()
$this->assertEquals($expectedArray, $array);
}

/**
* @test
*/
public function it_can_respond_with_a_single_item_at_the_top_level()
{
$respondWithItem = $this->getMethod('respondWithItem');
$testController = new TestController();

$response = $respondWithItem->invokeArgs($testController, [$this->testBooks[0], new TestTransformer(), false]);
$array = json_decode(json_encode($response->getData()), true);

$expectedArray = [
'id' => 1, 'author' => 'Philip K Dick', ];

$this->assertEquals($expectedArray, $array);
}

/**
* @test
*/
Expand Down Expand Up @@ -122,15 +139,38 @@ public function it_can_respond_with_a_collection()
$respondWithCollection = $this->getMethod('respondWithCollection');
$testController = new TestController();

$expectedData = [
['id' => 1, 'author' => 'Philip K Dick'],
['id' => 2, 'author' => 'George R. R. Satan'],
];

$response = $respondWithCollection->invokeArgs($testController, [$this->testBooks, new TestTransformer()]);
$array = json_decode(json_encode($response->getData()), true);

$expectedArray = ['data' => [
$this->assertEquals(['data' => $expectedData], $array);
}

/**
* @test
*/
public function it_can_respond_with_a_collection_as_a_top_level_item()
{
$respondWithCollection = $this->getMethod('respondWithCollection');
$testController = new TestController();

$expectedData = [
['id' => 1, 'author' => 'Philip K Dick'],
['id' => 2, 'author' => 'George R. R. Satan'],
]];
];

$this->assertEquals($expectedArray, $array);
$response = $respondWithCollection->invokeArgs($testController, [
$this->testBooks,
new TestTransformer(),
false
]);
$array = json_decode(json_encode($response->getData()), true);

$this->assertEquals($expectedData, $array);
}

/**
Expand Down
24 changes: 0 additions & 24 deletions tests/Integration/ForeignTransformerTest.php

This file was deleted.

Loading

0 comments on commit 5a32937

Please sign in to comment.