/** * @test * @fixture("Store") */ function notEmptySuccessTest() { $request = $this->sendRequest(self::API_NAMESPACE, self::API_CONTROLLER, self::ACTION); $this->assertEquals('200 OK', $request->getStatusCode()); $json = json_decode($request->getContent()); $this->assertNotEquals(0, Store::count()); $this->assertEquals(count($json->data), Store::count()); foreach ($json->data as $data) { $this->assertNotEmpty($data->id); $this->assertNotEmpty($data->name); $this->assertNotEmpty($data->user); $this->assertNotEmpty($data->created_at); $this->assertNotEmpty($data->updated_at); } }
public function load() { $file = file_get_contents(__DIR__ . '/data/store.json'); $fileData = json_decode($file); foreach ($fileData as $data) { $entity = new Store(); $entity->setName($data->name); $entity->setUser($data->{'user-id'}); $entity->save(); if (!$entity->save()) { throw new \Exception('Save fail: ' . implode("\n", $entity->getMessages())); } } }
/** * @SWG\Get( * path="/stores/{store}", * tags={"Store"}, * operationId="getStore", * summary="Buscar tienda", * @SWG\Parameter( * name="store", * in="path", * type="integer", * required=true * ), * @SWG\Response( * response="200", * description="OK", * @SWG\Schema(ref="#/definitions/store") * ) * ) */ public function findAction($store) { $store = Store::findFirst($store); return $this->modelsResponse($store); }