Skip to content

Commit ca2c74b

Browse files
committed
ÂAdded tests for IdentifierCollection
1 parent 38ed6f6 commit ca2c74b

File tree

1 file changed

+5
-35
lines changed

1 file changed

+5
-35
lines changed

tests/unit/Resource/IdentifierCollection.php renamed to tests/unit/Resource/IdentifierCollectionTest.php

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,8 @@ public function testCreateWithIdentifier()
5757
$this->assertSame($collection->getKeys(), array(0, 1, 2));
5858

5959
$this->assertTrue($collection->has(0));
60-
$resource = $collection->get(0);
61-
62-
$this->assertInstanceOf('Art4\JsonApiClient\Resource\ResourceInterface', $resource);
63-
$this->assertInstanceOf('Art4\JsonApiClient\Resource\Identifier', $resource);
64-
$this->assertNotInstanceOf('Art4\JsonApiClient\Resource\Item', $resource);
65-
6660
$this->assertTrue($collection->has(1));
67-
$resource = $collection->get(1);
68-
69-
$this->assertInstanceOf('Art4\JsonApiClient\Resource\ResourceInterface', $resource);
70-
$this->assertInstanceOf('Art4\JsonApiClient\Resource\Identifier', $resource);
71-
$this->assertInstanceOf('Art4\JsonApiClient\Resource\Item', $resource);
72-
7361
$this->assertTrue($collection->has(2));
74-
$resource = $collection->get(2);
75-
76-
$this->assertInstanceOf('Art4\JsonApiClient\Resource\ResourceInterface', $resource);
77-
$this->assertInstanceOf('Art4\JsonApiClient\Resource\Identifier', $resource);
78-
$this->assertNotInstanceOf('Art4\JsonApiClient\Resource\Item', $resource);
7962

8063
$this->assertSame($collection->asArray(), array(
8164
$collection->get(0),
@@ -108,7 +91,7 @@ public function testCreateWithItem()
10891
$this->assertInstanceOf('Art4\JsonApiClient\Resource\Collection', $collection);
10992

11093
$this->assertTrue($collection->isCollection());
111-
$this->assertCount($collection->asArray(), 1);
94+
$this->assertCount(1, $collection->asArray());
11295
$this->assertSame($collection->getKeys(), array(0));
11396
$this->assertTrue($collection->has(0));
11497

@@ -140,22 +123,6 @@ public function testCreateWithoutArrayThrowsException($input)
140123
$collection = new IdentifierCollection($input, $this->manager);
141124
}
142125

143-
/**
144-
* @dataProvider jsonValuesProvider
145-
*/
146-
public function testCreateWithoutObjectInArrayThrowsException($input)
147-
{
148-
// Input must be an object
149-
if ( gettype($input) === 'object' )
150-
{
151-
return;
152-
}
153-
154-
$this->setExpectedException('Art4\JsonApiClient\Exception\ValidationException');
155-
156-
$collection = new IdentifierCollection(array($input), $this->manager);
157-
}
158-
159126
/**
160127
* @test get('resources') on an empty identifier collection throws an exception
161128
*/
@@ -167,7 +134,10 @@ public function testGetResourcesWithEmptyCollectionThrowsException()
167134

168135
$this->assertFalse($collection->has(0));
169136

170-
$this->setExpectedException('Art4\JsonApiClient\Exception\AccessException');
137+
$this->setExpectedException(
138+
'Art4\JsonApiClient\Exception\AccessException',
139+
'"0" doesn\'t exist in this resource.'
140+
);
171141

172142
$collection->get(0);
173143
}

0 commit comments

Comments
 (0)