/** * test grabbing a Product by alertId **/ public function testGetValidProductByAlertId() { // count the number of rows and save it for later $numRows = $this->getConnection()->getRowCount("alertLevel"); // create a new alertLevel and insert to into mySQL $alertLevel = new AlertLevel(null, $this->VALID_alertCode, $this->VALID_alertFrequency, $this->VALID_alertPoint, $this->VALID_alertOperator); $alertLevel->insert($this->getPDO()); // create a new productAlert and insert to into mySQL $productAlert = new productAlert($alertLevel->getAlertId(), $this->product->getProductId(), true); $productAlert->insert($this->getPDO()); // grab the data from mySQL and enforce the fields match our expectations $pdoProductArray = AlertLevel::getProductByAlertId($this->getPDO(), $alertLevel->getAlertId()); for ($i = 0; $i < count($pdoProductArray); $i++) { if ($i === 0) { $this->assertSame($pdoProductArray[$i]->getAlertCode(), $this->VALID_alertCode); $this->assertSame($pdoProductArray[$i]->getAlertFrequency(), $this->VALID_alertFrequency); $this->assertSame($pdoProductArray[$i]->getAlertPoint(), $this->VALID_alertPoint); $this->assertSame($pdoProductArray[$i]->getAlertOperator(), $this->VALID_alertOperator); } else { $this->assertSame($pdoProductArray[$i]->getProductId(), $this->product->getProductId()); $this->assertSame($pdoProductArray[$i]->getVendorId(), $this->product->getVendorId()); $this->assertSame($pdoProductArray[$i]->getDescription(), $this->product->getDescription()); $this->assertSame($pdoProductArray[$i]->getSku(), $this->product->getSku()); $this->assertSame($pdoProductArray[$i]->getTitle(), $this->product->getTitle()); } } }
/** * test grabbing location by productId **/ public function testGetValidProductByLocationId() { // count the number of rows and save it for later $numRows = $this->getConnection()->getRowCount("location"); // create a new location and insert to into mySQL $location = new Location(null, $this->VALID_storageCode, $this->VALID_description); $location->insert($this->getPDO()); $quantity = 5.9; // create a new location and insert to into mySQL $productLocation = new productLocation($location->getLocationId(), $this->product->getProductId(), $this->unitOfMeasure->getUnitId(), $quantity); $productLocation->insert($this->getPDO()); // grab the data from mySQL and enforce the fields match our expectations $pdoProductArray = Location::getProductByLocationId($this->getPDO(), $location->getLocationId()); for ($i = 0; $i < count($pdoProductArray); $i++) { if ($i === 0) { $this->assertSame($pdoProductArray[$i]->getStorageCode(), $this->VALID_storageCode); $this->assertSame($pdoProductArray[$i]->getDescription(), $this->VALID_description); } else { $this->assertSame($pdoProductArray[$i]->getProductId(), $this->product->getProductId()); $this->assertSame($pdoProductArray[$i]->getVendorId(), $this->product->getVendorId()); $this->assertSame($pdoProductArray[$i]->getDescription(), $this->product->getDescription()); $this->assertSame($pdoProductArray[$i]->getSku(), $this->product->getSku()); $this->assertSame($pdoProductArray[$i]->getTitle(), $this->product->getTitle()); } } }
public function testLocaleTagChain() { PropelL10n::addDependency('it-IT', 'en'); $p = new \Product(); $p->setTitle('bene', 'it'); $p->setTitle('good', 'en'); $this->assertEquals('bene', $p->getTitle('it-IT')); }
public function add(Product $toBeAdded) { $stmt = $this->database->prepare("INSERT INTO `store`.`Products` (\n\t\t\t`pk` , `title` , `description` , `price` )\n\t\t\t\tVALUES (?, ?, ?, ?)"); if ($stmt === FALSE) { throw new \Exception($this->database->error); } $pk = $toBeAdded->getUniqueString(); $title = $toBeAdded->getTitle(); $description = $toBeAdded->getDescription(); $price = $toBeAdded->getPrice(); $stmt->bind_param('sssd', $pk, $title, $description, $price); $stmt->execute(); }
function shortRender(Product $p, BillingPlan $plan = null) { return $p->getTitle() . ' - ' . $plan->getTerms(); }
public static function updateProductsByIssue($issue_id, $products, $versions) { $old = self::getProductsByIssue($issue_id); $changes = array(); foreach ($products as $ipv_id => $pro_id) { if ($ipv_id == 0) { $old[] = array('ipv_id' => 0, 'pro_id' => '', 'product' => '', 'version' => ''); self::addIssueProductVersion($issue_id, $pro_id, $versions[$ipv_id]); } else { self::updateProductAndVersion($ipv_id, $pro_id, $versions[$ipv_id]); } } foreach ($old as $row) { $ipv_id = $row['ipv_id']; if ($row['pro_id'] != $products[$ipv_id]) { $changes[] = "Product changed from '" . $row['product'] . "' to '" . Product::getTitle($products[$ipv_id]); } if ($row['version'] != $versions[$ipv_id]) { $changes[] = "Product version changed from '" . $row['version'] . "' to '" . $versions[$ipv_id] . "'"; } } return $changes; }
public function addItem(Product $item) { echo '<p>' . $item->getTitle() . ' added</p>'; }
/** * Returns an array of active filters * * @param array $options The options array * @return array */ public static function getActiveFilters($options) { $prj_id = Auth::getCurrentProject(); $filter_info = self::getFiltersInfo(); $return = array(); foreach ($filter_info as $filter_key => $filter) { $display = false; if (isset($filter['param']) && isset($options[$filter['param']])) { $filter_details = $options[$filter['param']]; } if (isset($filter['is_custom'])) { // custom fields $fld_id = $filter['fld_id']; if (!isset($options['custom_field'][$fld_id]) || empty($options['custom_field'][$fld_id])) { continue; } elseif ($filter['fld_type'] == 'date' && empty($options['custom_field'][$fld_id]['Year'])) { continue; } elseif ($filter['fld_type'] == 'integer') { if (!isset($options['custom_field'][$fld_id]['value']) || empty($options['custom_field'][$fld_id]['value'])) { continue; } else { $filter_details = $options['custom_field'][$fld_id]; switch ($filter_details['filter_type']) { case 'ge': $display = ev_gettext('%1$s or greater', $filter_details['value']); break; case 'le': $display = ev_gettext('%1$s or less', $filter_details['value']); break; case 'gt': $display = ev_gettext('Greater than %1$s', $filter_details['value']); break; case 'lt': $display = ev_gettext('Less than %1$s', $filter_details['value']); break; default: $display = $filter_details['value']; } } } elseif (in_array($filter['fld_type'], array('multiple', 'combo'))) { $display = implode(', ', Custom_Field::getOptions($fld_id, $options['custom_field'][$fld_id])); } else { $display = $options['custom_field'][$fld_id]; } } elseif (!isset($options[$filter['param']]) || empty($options[$filter['param']]) || in_array($filter_key, array('sort_order', 'sort_by', 'rows', 'search_type'))) { continue; } elseif (isset($filter['is_date']) && $filter['is_date'] == true) { if (!empty($filter_details['Year']) || isset($filter_details['time_period'])) { switch ($filter_details['filter_type']) { case 'in_past': $display = ev_gettext('In Past %1$s hours', $filter_details['time_period']); break; case 'null': $display = ev_gettext('Is NULL'); break; case 'between': $end = $options[$filter['param'] . '_end']; $display = ev_gettext('Is between %1$s-%2$s-%3$s AND %4$s-%5$s-%6$s', $filter_details['Year'], $filter_details['Month'], $filter_details['Day'], $end['Year'], $end['Month'], $end['Day']); break; case 'greater': $display = ev_gettext('Is greater than %1$s-%2$s-%3$s', $filter_details['Year'], $filter_details['Month'], $filter_details['Day']); break; case 'less': $display = ev_gettext('Is less than %1$s-%2$s-%3$s', $filter_details['Year'], $filter_details['Month'], $filter_details['Day']); } } } elseif ($filter['param'] == 'status') { $statuses = Status::getAssocStatusList($prj_id); $display = $statuses[$filter_details]; } elseif ($filter['param'] == 'category') { $categories = Category::getAssocList($prj_id); if (is_array($filter_details)) { $active_categories = array(); foreach ($filter_details as $category) { $active_categories[] = $categories[$category]; } $display = implode(', ', $active_categories); } else { $display = $categories[$filter_details]; } } elseif ($filter['param'] == 'priority') { $priorities = Priority::getAssocList($prj_id); $display = $priorities[$filter_details]; } elseif ($filter['param'] == 'severity') { $severities = Severity::getAssocList($prj_id); $display = $severities[$filter_details]; } elseif ($filter['param'] == 'users') { if ($filter_details == -1) { $display = ev_gettext('un-assigned'); } elseif ($filter_details == -2) { $display = ev_gettext('myself and un-assigned'); } elseif ($filter_details == -3) { $display = ev_gettext('myself and my group'); } elseif ($filter_details == -4) { $display = ev_gettext('myself, un-assigned and my group'); } elseif (substr($filter_details, 0, 3) == 'grp') { $display = ev_gettext('%1$s Group', Group::getName(substr($filter_details, 4))); } else { $display = User::getFullName($filter_details); } } elseif ($filter['param'] == 'hide_closed') { if ($filter_details == true) { $display = ev_gettext('Yes'); } } elseif ($filter['param'] == 'reporter') { $display = User::getFullName($filter_details); } elseif ($filter['param'] == 'release') { $display = Release::getTitle($filter_details); } elseif ($filter['param'] == 'customer_id') { try { $crm = CRM::getInstance($prj_id); $customer = $crm->getCustomer($filter_details); $display = $customer->getName(); } catch (CRMException $e) { $display = $filter_details; } } elseif ($filter['param'] == 'product') { $display = Product::getTitle($filter_details); } else { $display = $filter_details; } if ($display != false) { $return[$filter['title']] = array('value' => $display, 'remove_link' => 'list.php?view=clearandfilter&' . self::buildUrl($filter_info, $options, $filter_key, true)); } } return $return; }
/** * test grabbing a Product by title **/ public function testGetValidProductByTitle() { // create a new Product $newProduct = new Product(null, $this->vendor->getVendorId(), $this->VALID_description, $this->VALID_leadTime, $this->VALID_sku, $this->VALID_title); $newProduct->insert($this->getPDO()); // grab the data from guzzle and enforce the status' match our expectations $response = $this->guzzle->get('https://bootcamp-coders.cnm.edu/~invtext/backend/php/api/product/?title=' . $newProduct->getTitle()); $this->assertSame($response->getStatusCode(), 200); $body = $response->getBody(); // echo $body . PHP_EOL; $product = json_decode($body); $this->assertSame(200, $product->status); }
/** * test grabbing an product by alert Id **/ public function testGetValidNotificationsByAlertId() { // create a new notification and insert to into mySQL $notification = new Notification(null, $this->alertLevel->getAlertId(), $this->VALID_emailStatus, $this->VALID_notificationDateTime, $this->VALID_notificationHandle, $this->VALID_notificationContent); $notification->insert($this->getPDO()); // grab the data from mySQL and enforce the fields match our expectations $pdoProductArray = Notification::getProductByAlertId($this->getPDO(), $notification->getAlertId()); for ($i = 0; $i < count($pdoProductArray); $i++) { if ($i === 0) { $this->assertSame($pdoProductArray[$i]->getAlertId(), $this->alertLevel->getAlertId()); $this->assertSame($pdoProductArray[$i]->getEmailStatus(), $this->VALID_emailStatus); $this->assertEquals($pdoProductArray[$i]->getNotificationDateTime(), $this->VALID_notificationDateTime); $this->assertSame($pdoProductArray[$i]->getNotificationHandle(), $this->VALID_notificationHandle); $this->assertSame($pdoProductArray[$i]->getNotificationContent(), $this->VALID_notificationContent); } else { $this->assertSame($pdoProductArray[$i]->getProductId(), $this->product->getProductId()); $this->assertSame($pdoProductArray[$i]->getVendorId(), $this->product->getVendorId()); $this->assertSame($pdoProductArray[$i]->getDescription(), $this->product->getDescription()); $this->assertSame($pdoProductArray[$i]->getSku(), $this->product->getSku()); $this->assertSame($pdoProductArray[$i]->getTitle(), $this->product->getTitle()); } } }
/** * test grabbing a Product by title **/ public function testGetValidProductByTitle() { // count the number of rows and save it for later $numRows = $this->getConnection()->getRowCount("product"); // create a new Product and insert to into mySQL $product = new Product(null, $this->vendor->getVendorId(), $this->VALID_description, $this->VALID_leadTime, $this->VALID_sku, $this->VALID_title); $product->insert($this->getPDO()); // grab the data from mySQL and enforce the fields match our expectations $pdoProducts = Product::getProductByTitle($this->getPDO(), $product->getTitle()); $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("product")); foreach ($pdoProducts as $pdoProduct) { $this->assertSame($pdoProduct->getVendorId(), $this->vendor->getVendorId()); $this->assertSame($pdoProduct->getDescription(), $this->VALID_description); $this->assertSame($pdoProduct->getLeadTime(), $this->VALID_leadTime); $this->assertSame($pdoProduct->getSku(), $this->VALID_sku); $this->assertSame($pdoProduct->getTitle(), $this->VALID_title); } }
<?php require_once 'product.php'; $myProduct = new Product('php for dummies', 'boek'); $myProduct2 = new Product('hoi', 'film'); // $myProduct-> getTitle(); echo "Title: "; echo $myProduct->getTitle(); echo '<br>'; echo 'dit is een:'; echo $myProduct->getType(); echo '<br>'; echo $myProduct2->getTitle(); echo '<br>'; echo 'dit is een:'; echo $myProduct2->getType();