コード例 #1
0
 public function testItemId()
 {
     $expected = 'item123';
     $this->assertNull($this->item->getItemId());
     $this->assertSame($this->item, $this->item->setItemId($expected));
     $this->assertEquals($expected, $this->item->getItemId());
 }
コード例 #2
0
 public function testToArray()
 {
     $data = ['actionCode' => 'LOGIN', 'item' => ['id' => 'The Item', 'title' => 'The Item', 'description' => 'The Item\'s description', 'author' => 'john.doe'], 'categories' => ['foo', 'bar']];
     $item = new Item();
     $item->setItemId('The Item')->setTitle('The Item')->setDescription('The Item\'s description')->setAuthor('john.doe');
     $this->action->fromArray($data);
     $this->action->setItem($item);
     $actionArray = $this->action->toArray();
     $this->assertCount(3, $actionArray);
     $this->assertEquals($data, $actionArray);
 }
コード例 #3
0
 public function testNotifyInteractionWIthItem()
 {
     $history = new History();
     $this->client->getEmitter()->attach($history);
     $this->subscriber->addResponse(new Response(200, [], new Stream(fopen('data://text/plain,[]', 'r'))));
     $this->client->notifyInteraction('user', 'target-user', 'RATE', 'the-item');
     $contents = $history->getLastRequest()->getBody()->__toString();
     $request = json_decode($contents, true);
     $this->assertEquals(['userId' => 'user', 'interactionCode' => 'RATE', 'targetUserId' => 'target-user', 'item' => ['id' => 'the-item']], $request);
     $this->subscriber->addResponse(new Response(200, [], new Stream(fopen('data://text/plain,[]', 'r'))));
     $item = new Item();
     $item->setItemId('the-item')->setAuthor('the-author');
     $this->client->notifyInteraction('user', 'target-user', 'RATE', $item);
     $contents = $history->getLastRequest()->getBody()->__toString();
     $request = json_decode($contents, true);
     $this->assertEquals(['userId' => 'user', 'interactionCode' => 'RATE', 'targetUserId' => 'target-user', 'item' => $item->toArray()], $request);
 }