PHPackages                             ohseesoftware/laravel-veneer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. ohseesoftware/laravel-veneer

ActiveLibrary[Testing &amp; Quality](/categories/testing)

ohseesoftware/laravel-veneer
============================

Laravel Veneer offers a suite of fixture data and mocking methods for you to use to coverage the 80% of mocking 3rd party services.

v1.4.0(4y ago)4435MITPHPPHP &gt;=8.0

Since Dec 31Pushed 4y ago1 watchersCompare

[ Source](https://github.com/ohseesoftware/laravel-veneer)[ Packagist](https://packagist.org/packages/ohseesoftware/laravel-veneer)[ Docs](https://github.com/ohseesoftware/laravel-veneer)[ RSS](/packages/ohseesoftware-laravel-veneer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (8)Versions (6)Used By (0)

Laravel Veneer
==============

[](#laravel-veneer)

A suite of fixture data and methods to help make mocking 3rd party services easier.

Overview
--------

[](#overview)

Laravel Veneer aims to solve two problems for developers to assist with writing tests:

1. Provide static response data (fixtures) from 3rd party APIs
2. Provide SDK-specific abstractions on top of [Mockery](https://github.com/mockery/mockery) for mocking SDK calls

Both goals aim to help with 80% of the work needed for mocking/API responses, while leaving the remaining 20% up to the developer. As an example, Laravel Veneer will provide a generic mock and fixture for creating a new calendar via Cronofy, but if you need to test for a specific response, you'll need to mock that yourself.

### Fixtures

[](#fixtures)

Fixtures are static *response* data from 3rd party APIs such as Twitter, GitHub, Cronofy, etc. One goal of this package is to allow the community to contribute response fixtures for any available API.

### SDK Mocking

[](#sdk-mocking)

The SDK mocking layer is built specifically for Laravel, on top of Mockery. It allows developers to quickly mock various SDK calls for available 3rd party APIs, when using their SDK packages.

Installation
------------

[](#installation)

Install the package via composer:

```
composer require ohseesoftware/laravel-veneer

```

There's no service provider or anything registered, all classes are used directly in your test classes.

Usage
-----

[](#usage)

The goal of the package is to make mocking the 80% use case easy. There's three steps involved:

1. Create an instance of a `MockProvider`
2. Add the methods you want to mock to the `MockProvider`
3. Apply the mock

The simplest example is a one-liner:

```
$this->veneer(CronofyMock::make()->add(CreateChannelMock::make()));
```

Where we:

- Make a new instance of the `MockProvider`: `CronofyMock::make()`
- Add a method to mock: `->add(CreateChannelMock::make())`
- Apply the mock using the exposed trait: `$this->veneer(...)`

Here's an example of a full test class using the package to a mock Cronofy's `createChannel` method:

```
