Created
July 18, 2012 11:26
-
-
Save rickard2/3135689 to your computer and use it in GitHub Desktop.
WordPress tests with wpdb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class testWPDB extends wpdb { | |
function prepare( $query, $arguments ) | |
{ | |
return vsprintf( $query, $arguments ); | |
} | |
} | |
class UTCW_Test_Data extends WP_UnitTestCase { | |
protected $utcw; | |
function setUp() | |
{ | |
$this->utcw = UTCW_Plugin::get_instance(); | |
} | |
function getWPDBMock() | |
{ | |
return $this->getMock( 'testWPDB', array( 'get_results' ), array(), '', false ); | |
} | |
function test_author() | |
{ | |
$instance[ 'authors' ] = array( 1, 2, 3 ); | |
$config = new UTCW_Config( $instance, $this->utcw ); | |
$db = $this->getWPDBMock( 'get_results' ); | |
$db->expects( $this->once() ) | |
->method( 'get_results' ) | |
->with( $this->stringContains( 'post_author IN (1,2,3)' ) ); | |
$data = new UTCW_Data( $config, $db ); | |
$data->get_terms(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment