/**
  * test inserting an organization and regrabbing it from mySQL
  */
 public function testGetValidListingTypeById()
 {
     //count the rows in the database
     $numRows = $this->getConnection()->getRowCount("listingType");
     $listingtype = new ListingType(null, $this->VALID_TYPE);
     $listingtype->insert($this->getPDO());
     //grab data from SQL and ensure it matches
     $pdoListingType = ListingType::getListingTypeById($this->getPDO(), $listingtype->getListingTypeId());
     $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("listingType"));
     $this->assertSame($pdoListingType->getListingTypeInfo(), $this->VALID_TYPE);
 }
Exemple #2
0
    echo $form->labelEx($model, 'description');
    ?>
			<?php 
    echo $form->textArea($model, 'description', array('rows' => 6, 'cols' => 50, 'class' => "full"));
    ?>
			<?php 
    echo $form->error($model, 'description');
    ?>
		</div>
	
		<div class="row">
			<?php 
    echo $form->labelEx($model, 'type');
    ?>
			<?php 
    echo $form->dropDownList($model, 'type', CHtml::listData(ListingType::findAll(), 'id', 'name'));
    ?>
			<?php 
    echo $form->error($model, 'type');
    ?>
		</div>
	
		<table id="coupons" class="coupons">
	    <thead>
	        <tr>
	            <td>
	                <?php 
    echo CHtml::link('Add Coupon', '', array('onClick' => 'addCoupon($(this))', 'class' => 'listingAdd'));
    ?>
	            </td>
	        </tr>
Exemple #3
0
 public function getType($type)
 {
     return ListingType::getType($type);
 }
Exemple #4
0
                 throw new RuntimeException("Listing type does not exist", 404);
             }
             $listingType = new ListingType($id, $requestObject->listingType);
             $listingType->update($pdo);
             $reply->message = "Listing type updated OK";
         } else {
             if ($method === "POST") {
                 $listingType = new ListingType(null, $requestObject->listingType);
                 $listingType->insert($pdo);
                 $reply->message = "Listing type created OK";
             }
         }
     } else {
         if ($method === "DELETE") {
             //verifyXsrf();
             $listingType = ListingType::getListingTypeById($pdo, $id);
             if ($listingType === null) {
                 throw new RuntimeException("Listing type does not exist", 404);
             }
             $listingType->delete($pdo);
             $deletedObject = new stdClass();
             $deletedObject->listingTypeId = $id;
             $reply->message = "Listing type deleted OK";
         }
     }
 } else {
     //if not an admin, and attempting a method other than get, throw an exception
     if (empty($method) === false && $method !== "GET") {
         throw new RuntimeException("Only administrators are allowed to modify entries", 401);
     }
 }
 /**
  * test getting all listing Types
  */
 public function testValidGetAll2()
 {
     //test getting by parameter new listing type
     //create a new listing type, and insert into the database
     $listingType = new ListingType(null, $this->VALID_TYPE_2);
     $listingType->insert($this->getPDO());
     $listingType = new ListingType(null, $this->VALID_TYPE);
     $listingType->insert($this->getPDO());
     //send the get request to the API
     $response = $this->guzzle->get('https://bootcamp-coders.cnm.edu/~tfenstermaker/bread-basket/public_html/php/api/listingtype', ['headers' => ['X-XSRF-TOKEN' => $this->token]]);
     //ensure the response was sent, and the api returned a positive status
     $this->assertSame($response->getStatusCode(), 200);
     $body = $response->getBody();
     $retrievedListingType = json_decode($body);
     $this->assertSame(200, $retrievedListingType->status);
     //ensure the response returned a non-empty array
     $this->assertGreaterThan(0, sizeof($retrievedListingType->data->listingTypeId));
 }