2017 © Pedro Peláez
 

library mock-php-stream

Stream wrapper for mocking php://

image

syberisle/mock-php-stream

Stream wrapper for mocking php://

  • Tuesday, June 12, 2018
  • by dlundgren
  • Repository
  • 1 Watchers
  • 0 Stars
  • 84 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

php:// Mock Library

Travis CI Code Climate, (*1)

This library is intended to be used to mock the php:// stream wrapper., (*2)

It's highly recommended that you register/unregister this ONLY when you need it in a test. Otherwise it could interfere with other built-in php streams during the course of it being registered., (*3)

Installation

composer install syberisle/mock-php-stream, (*4)

Usage

Using this to test a Slim 3 app's ability to do direct file uploads, where the body IS the content, is now easier., (*5)

MockPhpStream::register();
file_put_contents('php://input', 'you test data');

$app = new Slim\App();
$app->post('', function ($request) {
    // direct file uploads
    $request->getBody()->detach();
    $from = fopen("php://input", 'r');
    $to   = fopen('/my/path/file', 'w');
    stream_copy_to_stream($from, $to);
    fclose($from);
    fclose($to);
});

MockPhpStream::unregister();

Security

Using this in production could potentially cause problems as it overrides the built-in php stream functions., (*6)

Credits

The idea was based off on this blog article Mocking php://input., (*7)

License

The MIT License (MIT). Please see License File for more information., (*8)

The Versions

12/06 2018

dev-master

9999999-dev

Stream wrapper for mocking php://

  Sources   Download

MIT

The Development Requires

12/06 2018

1.0.1

1.0.1.0

Stream wrapper for mocking php://

  Sources   Download

MIT

The Development Requires

10/06 2018

1.0.0

1.0.0.0

Stream wrapper for mocking php://

  Sources   Download

MIT

The Development Requires