2017 © Pedro Peláez
 

library mock-extern-service

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

image

tumtum/mock-extern-service

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

  • Saturday, June 10, 2017
  • by TumTum
  • Repository
  • 1 Watchers
  • 0 Stars
  • 297 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 2 Versions
  • 9 % Grown

The README.md

Mock Extern Service

Build Status, (*1)

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

Installation

composer require --dev "tumtum/mock-extern-service", (*3)

Booting

At first to you must booting this system, that can you do in the bootstrap file see., (*4)

\tm\MockExternService\Service::boot();

Than you must start PHPUnit with PHP interpreter option -d sendmail_path=[vendor/]bin/smtp-mock-server.php This script will mock the Mail System., (*5)

Assert

Mock Mails System

with tm\MockExternService\Result::MailInbox() get you the mail Content., (*6)

The PHP ini "sendmail_path" must be set to 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), (*7)

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

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

Mock UDP Socket

with tm\MockExternService\Result::UdpSockArrived() get you 2048 Bit of Content. Socket will be listen on:, (*8)

host port
127.0.0.1 13010
Sample:
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:

See PHPUnitTest command: php -d sendmail_path=mock-service/smtp-mock-server.php ./vendor/bin/phpunit., (*9)

Chanelog

  • v0.1 First Idea

The Versions

10/06 2017

dev-master

9999999-dev

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

  Sources   Download

MIT

The Development Requires

by Tobias Matthaiou

mail tdd mock phpunit socket mock mail

09/06 2017

v0.1.1

0.1.1.0

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

  Sources   Download

MIT

The Development Requires

by Tobias Matthaiou