PHPackages                             ericfortmeyer/mock-extern-service - 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. ericfortmeyer/mock-extern-service

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

ericfortmeyer/mock-extern-service
=================================

To mock service like mail or UDP socket for functional Tests. TDD, PHPUnit

v0.2.2(5y ago)010MITPHP

Since Jun 9Pushed 5y agoCompare

[ Source](https://github.com/ericfortmeyer/mock-extern-service)[ Packagist](https://packagist.org/packages/ericfortmeyer/mock-extern-service)[ RSS](/packages/ericfortmeyer-mock-extern-service/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (1)Versions (5)Used By (0)

Mock Extern Service
===================

[](#mock-extern-service)

[![Build Status](https://camo.githubusercontent.com/7ccd725b4ea4da4b3f04029c666f58026ebc335cfd68a63a34c0d7454de6f06b/68747470733a2f2f7472617669732d63692e6f72672f746d6c6f6265726f6e2f6d6f636b2d65787465726e2d736572766963652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/tmloberon/mock-extern-service)

To mock service like mail or UDP socket for functional Tests. The result will be saved in a file and that can you assert.

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

[](#installation)

*composer require --dev "ericfortmeyer/mock-extern-service"*

Booting
-------

[](#booting)

At first to you must booting this system, that can you do in the bootstrap file [see](tests/bootstrap.php).

```
\Fortmeyer\MockExternService\Service::boot();

```

Than you must start PHPUnit with PHP interpreter option `-d sendmail_path=mock-service/smtp-mock-server.php`This script will mock the Mail System.

Assert
------

[](#assert)

#### Mock Mails System

[](#mock-mails-system)

with `Fortmeyer\MockExternService\Result::MailInbox()` get you the mail Content.

The PHP ini "sendmail\_path" must be set to [smtp-mock-server.php](mock-service/smtp-mock-server.php) script. That get the Mail and save it. This config can only set befor starts the script. Like in php.ini or as command option (php -d)

###### Sample:

[](#sample)

```
public function testMockMailSystem()
{
    $msg = "Content " . time();
    mail('root@@127.0.0.1', "subject", $msg);

    $this->assertContains($msg, MockExternService\Result::MailInbox());
}

```

#### Mock UDP Socket

[](#mock-udp-socket)

with `Fortmeyer\MockExternService\Result::UdpSockArrived()` get you 2048 Bit of Content. Socket will be listen on:

hostport127.0.0.113010###### Sample:

[](#sample-1)

```
public function testGrayLogServer()
{
    $data = "graylog_data " . time();
    $socket = fsockopen('udp://127.0.0.1:13010');
    fputs($socket, $data);

    $this->assertEquals($data, MockExternService\Result::UdpSockArrived());
}

```

Sample:
-------

[](#sample-2)

See [PHPUnitTest](tests/) command: `php -d sendmail_path=mock-service/smtp-mock-server.php ./vendor/bin/phpunit`.

Chanelog
--------

[](#chanelog)

- v0.1 First Idea

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~473 days

Total

4

Last Release

1838d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/40972462?v=4)[Eric Fortmeyer](/maintainers/ericfortmeyer)[@ericfortmeyer](https://github.com/ericfortmeyer)

---

Top Contributors

[![ericfortmeyer](https://avatars.githubusercontent.com/u/40972462?v=4)](https://github.com/ericfortmeyer "ericfortmeyer (20 commits)")[![tmloberon](https://avatars.githubusercontent.com/u/28302826?v=4)](https://github.com/tmloberon "tmloberon (12 commits)")[![TumTum](https://avatars.githubusercontent.com/u/225997?v=4)](https://github.com/TumTum "TumTum (1 commits)")

---

Tags

phpunitmailTDDmockSocketmock mail

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ericfortmeyer-mock-extern-service/health.svg)

```
[![Health](https://phpackages.com/badges/ericfortmeyer-mock-extern-service/health.svg)](https://phpackages.com/packages/ericfortmeyer-mock-extern-service)
```

###  Alternatives

[mockery/mockery

Mockery is a simple yet flexible PHP mock object framework

10.7k497.0M23.5k](/packages/mockery-mockery)[php-mock/php-mock-phpunit

Mock built-in PHP functions (e.g. time()) with PHPUnit. This package relies on PHP's namespace fallback policy. No further extension is needed.

1718.2M397](/packages/php-mock-php-mock-phpunit)[codedungeon/phpunit-result-printer

PHPUnit Pretty Result Printer

1.2k8.8M397](/packages/codedungeon-phpunit-result-printer)[php-mock/php-mock

PHP-Mock can mock built-in PHP functions (e.g. time()). PHP-Mock relies on PHP's namespace fallback policy. No further extension is needed.

36918.1M98](/packages/php-mock-php-mock)[kahlan/kahlan

The PHP Test Framework for Freedom, Truth and Justice.

1.2k1.2M246](/packages/kahlan-kahlan)[lchrusciel/api-test-case

Perfect PHPUnit TestCase for JSON/XML API TDD with Symfony.

4115.5M63](/packages/lchrusciel-api-test-case)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
