/** * Verify Collection can handle a response with a single item. * * @test * * @return void */ public function oneItemCollection() { $client = new Client('not under tests', 'not under test', new SingleAdapter()); $collection = new Collection($client, 'not under tests'); foreach ($collection as $item) { $this->assertSame(0, $collection->current()->getId()); $this->assertSame('a title for comic 0', $collection->current()->getTitle()); } }
<?php require_once dirname(__DIR__) . '/vendor/autoload.php'; use Chadicus\Marvel\Api\Client; use Chadicus\Marvel\Api\Collection; $publicApiKey = getenv('PUBLIC_KEY'); $privateApiKey = getenv('PRIVATE_KEY'); $client = new Client($privateApiKey, $publicApiKey); //24 is the id of Bendis. 312 is the id of Deodato $collection = new Collection($client, 'comics', ['collaborators' => '24,312']); echo "{$collection->count()} results found\n"; foreach ($collection as $comic) { echo "{$comic->id}: {$comic->title}\n"; }