public static function setUpBeforeClass() { // for error reporting (need to run with php5.3 to get no warning) //ini_set('display_errors', 1); //error_reporting(~0); // new pet $new_pet_id = 10005; $new_pet = new Model\Pet(); $new_pet->setId($new_pet_id); $new_pet->setName("PHP Unit Test"); $new_pet->setStatus("available"); // new tag $tag = new Model\Tag(); $tag->setId($new_pet_id); // use the same id as pet $tag->setName("test php tag"); // new category $category = new Model\Category(); $category->setId($new_pet_id); // use the same id as pet $category->setName("test php category"); $new_pet->setTags(array($tag)); $new_pet->setCategory($category); $pet_api = new Api\PetAPI(); // add a new pet (model) $add_response = $pet_api->addPet($new_pet); }
/** * Instantiate a Pet from an image table id * @param int $petId id of pet row to create a Pet instance from * @return \Pet */ public static function constructById($petId) { $row = Model\Pet::getPetById($petId); $row = isset($row[0]) ? $row[0] : $row; if (isset($row['id'])) { $pet = self::constructByRow($row); $pet->setId($row['id']); return $pet; } return null; }
/** * Decline a pet posting * @return type string response page * @throws Exception */ public static function adminDecline() { // if (isset($_POST['id'])) { $get = Core\Input::get(); if (isset($get['petId'])) { //$petId = $_POST['id']; $petId = $get['petId']; $pet = Pet::constructById($petId); $pet->setApproved(2); $pet->setVisibility('n'); Model\Pet::updatePet($pet); } // ob_start(); // $url = 'http://sfsuswe.com/~nthanlee/index.php/PetBasket/admin'; // while (ob_get_status()) { // ob_end_clean(); // } // header("Location: $url"); }
public function testAddPet() { // initialize the API client $config = (new Configuration())->setHost('http://petstore.swagger.io/v2'); $api_client = new ApiClient($config); $new_pet_id = 10005; $new_pet = new Model\Pet(); $new_pet->setId($new_pet_id); $new_pet->setName("PHP Unit Test 2"); $pet_api = new Api\PetApi($api_client); // add a new pet (model) $add_response = $pet_api->addPet($new_pet); // return nothing (void) $this->assertSame($add_response, null); // verify added Pet $response = $pet_api->getPetById($new_pet_id); $this->assertSame($response->getId(), $new_pet_id); $this->assertSame($response->getName(), 'PHP Unit Test 2'); }