/** * Test if Application has reference can connect to the Documentation Site. * * @dataProvider documentationsURLDataProvider * @group rest.config.connection */ function testReferenceDocumentationsMustBeAccessible($url, $sanitized) { $acceptable_http_status = array(200, 301, 302, 304); $acceptable_http_status_text = implode(', ', $acceptable_http_status); $request = RestHelper::get($sanitized); $this->assertContains($request['head']['http_code'], $acceptable_http_status, 'HTTP Status when connecting to `' . $url . '`. Allows ' . $acceptable_http_status_text); }
public function testCompareEntitiesWithData() { $mockedObject = $this->getMock('stdClass', ['getId', 'getValue']); $mockedObject->expects($this->any())->method('getId')->will($this->returnValue(1)); $mockedObject->expects($this->any())->method('getValue')->will($this->returnValue(2)); $mockedObject2 = clone $mockedObject; $mockedObject3 = clone $mockedObject; $mock = $this->getMock('stdClass', ['delete', 'update', 'add', 'get']); $mock->expects($this->once())->method('delete'); $mock->expects($this->any())->method('update'); $mock->expects($this->once())->method('add'); $mock->expects($this->any())->method('get'); $get = function ($entity, $data) { return isset($data['id']) && $data['id'] === $entity->getId() || isset($data['value']) && $data['value'] === $entity->getValue(); }; $delete = function () use($mock) { $mock->delete(); return true; }; $update = function () use($mock) { $mock->update(); return true; }; $add = function () use($mock) { $mock->add(); return true; }; $this->restHelper->compareEntitiesWithData([$mockedObject, $mockedObject2, $mockedObject3], [['id' => 1, 'value' => 3], ['id' => 2], ['value' => 2]], $get, $add, $update, $delete); }
public function actionUploadImage($name) { if (isset($_FILES['image']) && $_FILES['image']['error'] == 0) { //图片处理 $pic = '/data/www/db.admin.mofang.com/upload/cardimages/' . md5(time()) . '.jpg'; move_uploaded_file($_FILES['image']['tmp_name'], $pic); $url = Yii::app()->mcss->uploadImage($pic); unlink($pic); if (!isset($url['error'])) { RestHelper::success(array('url' => $url)); } else { RestHelper::error('图片上传到云存储失败'); } } else { RestHelper::error('图片上传失败'); } }