Skip to content

Commit

Permalink
Add Unit Test for whocalled.us
Browse files Browse the repository at this point in the history
  • Loading branch information
jfinstrom authored and tm1000 committed Sep 6, 2016
1 parent b0cd347 commit 6b4a926
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sources/source-Paginasblancas_AR.module
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Paginasblancas_AR extends superfecta_base {

$url = "http://www.paginasblancas.com.ar/telefono/".$thenumber; //updated 2014-08-05
$pattern = array(
'/<a class="no-link" href="javascript:void.0.;">(.*?)<\/a>/', //updated 2016-07-14 for residential
'/<a class="no-link" href="javascript:void.0.;">(.*?)<\/a>/', //updated 2016-07-14 for residential
'~<h3 class="m-results-business--name" itemprop="name">.*?<a href=".*?">(.+?)</a>.*?</h3>~s', // added 2014-07-11 for business
);

Expand Down
14 changes: 14 additions & 0 deletions utests/setuptests.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

<?php
/**
* https://blogs.kent.ac.uk/webdev/2011/07/14/phpunit-and-unserialized-pdo-instances/
* @backupGlobals disabled
* @backupStaticAttributes disabled
*/
global $amp_conf, $db;
if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) {
include_once('/etc/asterisk/freepbx.conf');
}
restore_error_handler();
error_reporting(-1);
error_reporting(E_ALL & ~(E_STRICT | E_NOTICE));
34 changes: 34 additions & 0 deletions utests/source-Who_CalledTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/**
* https://blogs.kent.ac.uk/webdev/2011/07/14/phpunit-and-unserialized-pdo-instances/
* @backupGlobals disabled
*/

class Who_CalledTest extends PHPUnit_Framework_TestCase{
protected static $o;
public static function setUpBeforeClass() {
include 'setuptests.php';
$webroot = FreePBX::Config()->get('AMPWEBROOT');
include $webroot.'/admin/modules/superfecta/includes/superfecta_base.php';
include $webroot.'/admin/modules/superfecta/sources/source-Who_Called.module';
self::$o = new Who_Called();
}
//Stuff before the test
public function setup() {}
//Leave this alone, it test that PHPUnit is working
public function testPHPUnit() {
$this->assertEquals("test", "test", "PHPUnit is broken.");
$this->assertNotEquals("test", "nottest", "PHPUnit is broken.");
}

//This tests that the the object for your class is an object
public function testCreate() {;
$this->assertTrue(is_object(self::$o), "Did not get an object");
}

public function testCnam(){
$cnam = self::$o->get_caller_id('6305424316',array('CNAM_Lookup' => true));
$this->assertEquals("Schaumburg%2C+IL", $cnam, "The lookup returned an unexpected result for 6305434316");
}
}

0 comments on commit 6b4a926

Please sign in to comment.