Ejemplo n.º 1
0
 /**
  * Test function checks the returned total and
  * results price total are same. 
  */
 public function testgetdata()
 {
     $testData = new mainScraper("http://hiring-tests.s3-website-eu-west-1.amazonaws.com/2015_Developer_Scrape/5_products.html");
     $json = $testData->getData();
     $testResult = json_decode($json, true);
     $results = $testResult['result'];
     $itemTotal = $testResult['total'];
     $total = 0;
     foreach ($results as $item) {
         $total += $item['unit_price'];
         echo $total;
     }
     /**
      * Assert here if the data is equal.
      */
     $this->assertEquals($total, $itemTotal);
 }
Ejemplo n.º 2
0
<?php

require 'mainScraper.php';
/**
 * 
 * @var unknown
 */
$url = "http://hiring-tests.s3-website-eu-west-1.amazonaws.com/2015_Developer_Scrape/5_products.html";
$dataHandler = new mainScraper($url);
/**
 * 
 * @var returned json array
 */
$jsonData = $dataHandler->getData();
print_r($jsonData);