Open Journal Systems
3.3.0
ModelTest.php
1
<?php
2
3
namespace
Guzzle\Tests\Service\Resource
;
4
5
use
Guzzle\Service\Resource\Model
;
6
use
Guzzle\Service\Description\Parameter
;
7
use
Guzzle\Common\Collection
;
8
12
class
ModelTest
extends
\Guzzle\Tests\GuzzleTestCase
13
{
14
public
function
testOwnsStructure
()
15
{
16
$param =
new
Parameter
(array(
'type'
=>
'object'
));
17
$model =
new
Model
(array(
'foo'
=>
'bar'
), $param);
18
$this->assertSame($param, $model->getStructure());
19
$this->assertEquals(
'bar'
, $model->get(
'foo'
));
20
$this->assertEquals(
'bar'
, $model[
'foo'
]);
21
}
22
23
public
function
testCanBeUsedWithoutStructure
()
24
{
25
$model =
new
Model
(array(
26
'Foo'
=>
'baz'
,
27
'Bar'
=> array(
28
'Boo'
=>
'Bam'
29
)
30
));
31
$transform =
function
($key, $value) {
32
return
($value && is_array($value)) ?
new
Collection
($value) : $value;
33
};
34
$model = $model->
map
($transform);
35
$this->assertInstanceOf(
'Guzzle\Common\Collection'
, $model->getPath(
'Bar'
));
36
}
37
38
public
function
testAllowsFiltering
()
39
{
40
$model =
new
Model
(array(
41
'Foo'
=>
'baz'
,
42
'Bar'
=>
'a'
43
));
44
$model = $model->filter(
function
($i, $v) {
45
return
$v[0] ==
'a'
;
46
});
47
$this->assertEquals(array(
'Bar'
=>
'a'
), $model->toArray());
48
}
49
50
public
function
testDoesNotIncludeEmptyStructureInString
()
51
{
52
$model =
new
Model
(array(
'Foo'
=>
'baz'
));
53
$str = (string) $model;
54
$this->assertContains(
'Debug output of model'
, $str);
55
$this->assertNotContains(
'Model structure'
, $str);
56
}
57
58
public
function
testDoesIncludeModelStructureInString
()
59
{
60
$model =
new
Model
(array(
'Foo'
=>
'baz'
),
new
Parameter
(array(
'name'
=>
'Foo'
)));
61
$str = (string) $model;
62
$this->assertContains(
'Debug output of Foo model'
, $str);
63
$this->assertContains(
'Model structure'
, $str);
64
}
65
}
Guzzle\Tests\GuzzleTestCase
Definition:
GuzzleTestCase.php:22
Guzzle\Service\Description\Parameter
Definition:
Parameter.php:10
Guzzle\Tests\Service\Resource\ModelTest\testCanBeUsedWithoutStructure
testCanBeUsedWithoutStructure()
Definition:
ModelTest.php:23
Guzzle\Tests\Service\Resource\ModelTest\testDoesNotIncludeEmptyStructureInString
testDoesNotIncludeEmptyStructureInString()
Definition:
ModelTest.php:50
Guzzle\Service\Resource\Model
Definition:
Model.php:11
Guzzle\Tests\Service\Resource
Definition:
CompositeResourceIteratorFactoryTest.php:3
Guzzle\Tests\Service\Resource\ModelTest
Definition:
ModelTest.php:12
Guzzle\Tests\Service\Resource\ModelTest\testOwnsStructure
testOwnsStructure()
Definition:
ModelTest.php:14
Guzzle\Tests\Service\Resource\ModelTest\testDoesIncludeModelStructureInString
testDoesIncludeModelStructureInString()
Definition:
ModelTest.php:58
Guzzle\Tests\Service\Resource\ModelTest\testAllowsFiltering
testAllowsFiltering()
Definition:
ModelTest.php:38
Guzzle\Common\Collection\map
map(\Closure $closure, array $context=array(), $static=true)
Definition:
paymethod/paypal/lib/vendor/guzzle/guzzle/src/Guzzle/Common/Collection.php:265
Guzzle\Common\Collection
Definition:
paymethod/paypal/lib/vendor/guzzle/guzzle/src/Guzzle/Common/Collection.php:11
plugins
paymethod
paypal
lib
vendor
guzzle
guzzle
tests
Guzzle
Tests
Service
Resource
ModelTest.php
Generated on Fri Aug 28 2020 14:52:46 for Open Journal Systems by
1.8.17