/** * NOTE: This service has not been fully tested * * @param File $file * @param int $rotation Degrees to rotate image clockwise, One value: 90, 180, 270 * * @throws UsageException * @return bool */ public function rotate(File $file, $rotation) { $params = array('rotation' => $rotation, 'token' => $this->api->getToken()); if (!is_null($file->getPageIdentifier()->getTitle())) { $params['titles'] = $file->getPageIdentifier()->getTitle()->getText(); } else { $params['pageids'] = $file->getPageIdentifier()->getId(); } $result = $this->api->postRequest(new SimpleRequest('imagerotate', $params)); // This module sometimes gives odd errors so deal with them.. if (array_key_exists('imagerotate', $result)) { $imageRotate = array_pop($result['imagerotate']); if (array_key_exists('result', $imageRotate) && $imageRotate['result'] == 'Failure') { throw new UsageException('imagerotate-Failure', $imageRotate['errormessage'], $result); } } return true; }
/** * @dataProvider provideValidConstruction */ public function testValidConstruction($url) { $file = new File($url, new PageIdentifier($this->newMockTitle(), 1), $this->newMockRevisions()); $this->assertEquals($url, $file->getUrl()); }