parser = new PublisherInfo(); $this->default_data = array( array("3", 'adboxid'), array("a", 'sitename'), array("a", 'adtype'), array("http://meow.raow/", 'url'), array("1x1", 'dimensions'), array("a", 'rating'), array("a", 'description'), array("a", 'tags'), array("a", 'standardcode'), array("a", 'advancedcode'), array(PW_ADBOXES_PROJECT_WONDERFUL, "type") ); } public static function badDataProvider() { return array( array(""), array("?xml version=\"1.0\""), array(''), array(''), array(''), array(''), array(''), array('aaaa'), array('aaaa'), array('aaaa') ); } /** * @dataProvider badDataProvider */ public function testBadPWData($string) { $this->assertFalse($this->parser->parse($string)); } public static function goodDataProvider() { return array( array(''), array('aaaa') ); } /** * @dataProvider goodDataProvider */ public function testGoodPWData($string) { $this->assertTrue($this->parser->parse($string)); } public function testPWAPI() { $this->parser->parse('aaaa'); $this->assertEquals(1, $this->parser->memberid); $this->assertEquals(1, count($this->parser->adboxes)); foreach ($this->default_data as $info) { list($value, $param) = $info; $this->assertEquals($value, $this->parser->adboxes[0]->{$param}, $param); } } function testGetSidebarInformation() { $this->parser->is_valid = true; $this->parser->memberid = "1"; $default_data_as_hash = array(); foreach ($this->default_data as $info) { list($value, $param) = $info; $default_data_as_hash[$param] = $value; } $this->parser->adboxes = array((object)$default_data_as_hash); $sidebar_info = array( array( "id" => "project_wonderful_1_{$default_data_as_hash['adboxid']}", "name" => "PW {$default_data_as_hash['sitename']} {$default_data_as_hash['dimensions']} {$default_data_as_hash['adtype']} ({$default_data_as_hash['adboxid']})", "options" => array("adboxid" => $default_data_as_hash['adboxid']) ) ); $this->assertEquals($sidebar_info, $this->parser->get_sidebar_widget_info()); $this->parser->is_valid = false; $this->assertFalse($this->parser->get_sidebar_widget_info()); } function testChangeSidebarAdType() { $this->parser->is_valid = true; $this->parser->memberid = "1"; $default_data_as_hash = array(); foreach ($this->default_data as $info) { list($value, $param) = $info; $default_data_as_hash[$param] = $value; } $this->parser->adboxes = array((object)$default_data_as_hash); } } function __($string, $domain) { return $string; } ?>