public function testToArray() { $ts = time(); $annotation = new Annotation('title', 'stream'); $annotation->start_time = $ts; $annotation->description = 'Example'; $payLoad = $annotation->toArray(); $this->assertInternalType('array', $payLoad); $this->assertSame('title', $payLoad['title']); $this->assertSame('stream', $annotation->getStream()); $this->assertSame(array('title' => 'title', 'description' => 'Example', 'start_time' => $ts), $payLoad); }
/** * Create an annotation event. * * @param string $stream the annotation stream (doesn't need to exist) * @param string $title the annotation title * @param string $source the annotation source * @param string $description the annotation description * @param int $start_time Unix timestamp for the start of the event * @param int $end_time Unix timestamp for the end of the event * @param string $rel the annotation link relationship * @param string $href the annotation link URL * @param string $label the annotation link label * * @todo the annotation link support doesn't work, don't know why * * @return boolean */ public function create($stream, $title, $source = null, $description = null, $start_time = null, $end_time = null, $rel = null, $href = null, $label = null) { $annotation = new Annotation($title, $stream); $annotation->source = $source; $annotation->description = $description; $annotation->start_time = $start_time; $annotation->end_time = $end_time; $annotation->rel = $rel; $annotation->href = $href; $annotation->label = $label; $response = $this->makeRequest('/annotations/' . $annotation->getStream(), Request2::METHOD_POST, $annotation->toArray()); return $response->getStatus() == 201; }