File: PsrHttpMessageStreamFactoryInterface.phpt

package info (click to toggle)
php-psr 1.2.0-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 548 kB
  • sloc: ansic: 1,485; pascal: 203; xml: 150; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 1,395 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
--TEST--
Psr\Http\Message\StreamFactoryInterface
--SKIPIF--
<?php include('skip.inc'); ?>
--FILE--
<?php
include __DIR__ . '/SampleStream.inc';
include __DIR__ . '/SampleStreamFactory.inc';
var_dump(interface_exists('\\Psr\\Http\\Message\\StreamFactoryInterface', false));
var_dump(class_implements('SampleStreamFactory', false));
$factory = new SampleStreamFactory();
$stream = $factory->createStream();
var_dump($stream instanceof \Psr\Http\Message\StreamInterface);
$factory->createStream('content');
$stream = $factory->createStreamFromFile('/tmp/file1');
var_dump($stream instanceof \Psr\Http\Message\StreamInterface);
$factory->createStreamFromFile('/tmp/file2', 'wb');
$stream = $factory->createStreamFromResource(fopen('php://memory', 'r'));
var_dump($stream instanceof \Psr\Http\Message\StreamInterface);
--EXPECTF--
bool(true)
array(1) {
  ["PsrExt\Http\Message\StreamFactoryInterface"]=>
  string(42) "PsrExt\Http\Message\StreamFactoryInterface"
}
string(33) "SampleStreamFactory::createStream"
string(0) ""
bool(true)
string(33) "SampleStreamFactory::createStream"
string(7) "content"
string(41) "SampleStreamFactory::createStreamFromFile"
string(10) "/tmp/file1"
string(1) "r"
bool(true)
string(41) "SampleStreamFactory::createStreamFromFile"
string(10) "/tmp/file2"
string(2) "wb"
string(45) "SampleStreamFactory::createStreamFromResource"
resource(%d) of type (stream)
bool(true)