/** Scraping Test **/ function testIMDBScrape() { $top250 = getIMDB250(); //print_r($top250); self::assert_equals(count($top250), 250); self::assert_equals($top250['111161']['title'], "The Shawshank Redemption"); }
<?php require_once "netflix.php"; require_once "scrape.php"; require_once "addict_database.php"; require_once "config.php"; //Title Change $dictionary = array('Il buono, il brutto, il cattivo.' => 'The Good, the Bad and the Ugly', 'Shichinin no samurai' => 'The Seven Samurai', "C'era una volta il West" => 'Once Upon a Time in the West', 'Cidade de Deus' => 'City of God', 'Léon' => 'The Professional', 'Le fabuleux destin d'Amélie Poulain' => 'Amélie', 'Das Leben der Anderen' => 'The Lives of Others', 'Sen to Chihiro no kamikakushi' => 'Spirited Away', 'El laberinto del fauno' => 'Pan\'s Labyrinth', 'Der Untergang' => 'Downfall', 'La vita è bella' => 'Life Is Beautiful', 'Nuovo cinema Paradiso' => 'Cinema Paradiso', 'Ladri di biciclette' => 'The Bicycle Thief', 'Det sjunde inseglet' => 'The Seventh Seal', 'Per qualche dollaro in più' => 'For a Few Dollars More', 'Smultronstället' => 'Wild Strawberries', 'Les diaboliques' => 'Diabolique', 'Le notti di Cabiria' => 'Nights of Cabiria', 'Le salaire de la peur' => 'The Wages of Fear', 'Amores perros' => 'Love\'s a Bitch', 'Låt den rätte komma in' => 'Let the Right One In', 'Hotaru no haka' => 'Grave of the Fireflies', 'La battaglia di Algeri' => 'The Battle of Algiers', 'Mou gaan dou' => 'Infernal Affairs', 'Nosferatu, eine Symphonie des Grauens' => 'Nosferatu the Vampire', 'Wo hu cang long' => 'Crouching Tiger, Hidden Dragon', 'Le scaphandre et le papillon' => 'The Diving Bell and the Butterfly', 'Mononoke-hime' => 'Princess Mononoke'); $ad = new AddictDatabase("brokenva_addicttest"); $nf = new Netflix($netflixKey, $netflixSecret); $top250 = getIMDB250(); updateTop250($top250); /** Update the top 250 table **/ function updateTop250($top250) { global $ad; global $dictionary; $current = $ad->getMovies(); $ad->resetIMDBRank(); $ad->resetNetflixInstant(); foreach ($top250 as $movie) { $nftitle = $movie['title']; if (in_array($movie['id'], array_keys($current))) { $ad->updateIMDBRank($movie['id'], $movie['imdb_rank']); echo "Updated '" . $movie['title'] . "' to #" . $movie['imdb_rank'] . "<br>"; } else { $ad->addMovie($movie['id'], $movie['title'], $movie['imdb_rank']); echo "Added '" . $movie['title'] . "' as #" . $movie['imdb_rank'] . "<br>"; } if (in_array(utf8_decode($movie['title']), array_keys($dictionary))) { $ad->updateMovieTitle($movie['id'], $dictionary[$movie['title']]);