Location: PHPKode > projects > OpenNitro > trunk/Tests/Nitro/Modules/NitroNews.inc.php
<?php
//
// +---------------------------------------------------------------------------+
// | Nitro :: Tests :: Modules :: NitroNews                                    |
// +---------------------------------------------------------------------------+
// | Copyright (c) 2003-2006 June Systems BV                                   |
// +---------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or modify it   |
// | under the terms of the GNU Lesser General Public License as published by  |
// | the Free Software Foundation; either version 2.1 of the License, or (at   |
// | your option) any later version.                                           |
// |                                                                           |
// | This library is distributed in the hope that it will be useful, but       |
// | WITHOUT ANY WARRANTY; without even the implied warranty of                |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser   |
// | General Public License for more details.                                  |
// |                                                                           |
// | You should have received a copy of the GNU Lesser General Public License  |
// | along with this library; if not, write to the Free Software Foundation,   |
// | Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA            |
// +---------------------------------------------------------------------------+
// | Authors: Joris Osterhaus <hide@address.com>                |
// +---------------------------------------------------------------------------+
//
// $Id: NitroNews.inc.php 228 2008-04-16 14:05:37Z oli $
//

/**
 * Set error_reporting
 */
error_reporting(E_ALL & ~E_NOTICE);

/**
 * Include required files
 */
require_once NITRO_ROOT.'Nitro/Modules/NitroNews.inc.php';

/**
 * NitroNews TestCase
 */
class NitroNews_Test extends Nitro_TestCase {
	
	function NitroNews_Test($Name = "NitroNews_Test")
	{
		parent::Nitro_TestCase($Name);
	}
	
	function setUp()
	{
		$this->PrepareDatabaseTable('News', 'General');
		$this->PrepareDatabaseTable('NewsCategory', 'General');
		$this->NitroNews = new NitroNews();
	}
	
	function tearDown()
	{
		$this->CleanDatabaseTables();
		
		unset($this->NitroNews);
	}
	
	function test_UserRights()
	{
		$this->NitroNews->Sess->SecurityGroups[0] = 0;
		$this->AssertEquals('', $this->NitroNews->UserRights());
		$this->NitroNews->Sess->SecurityGroups[0] = 1;
		$this->AssertEquals('', $this->NitroNews->UserRights());
		$this->NitroNews->Sess->SecurityGroups[0] = 2;
		$this->AssertEquals('admin', $this->NitroNews->UserRights());
	}
	
	function test_NewsMenuQuery()
	{
		$expected = array(
			1 => array(
				'NewsCategoryID' => '1',
				'Name' => 'Generic',
				'Description' => 'Generic News for the masses '
			),
			2 => array(
				'NewsCategoryID' => '2',
				'Name' => 'Technology',
				'Description' => 'Latest and the greatest in technology'
			),
			3 => array(
				'NewsCategoryID' => '3',
				'Name' => 'Politics',
				'Description' => "What's up with politics today"
			)
		);
		$this->AssertEquals(serialize($expected), serialize($this->NitroNews->NewsMenuQuery()));
	}
	
	function test_SelectArticle()
	{
		$expected = array (
		 'NewsID' => '9',
		 'NewsCategoryID' => '1',
		 'VisibleFrom' => '2006-12-11 00:00:00',
		 'VisibleTill' => '2007-12-18 00:00:00',
		 'Title' => 'ouhetgie', 
		 'Leader' => 'iurgeiu',
		 'NewsText' => 'regegeiuebri;jub',
		 'Published' => '1', 
		 'CreatedByUserID' => '1',
		 'CreatedOn' => '2006-12-12 00:00:00',
		 'EditedByUserID' => null, 
		 'EditedOn' => null, 
		 'Name' => 'Generic',
		 'Description' => 'Generic News for the masses '
		);
		$this->AssertEquals($expected, $this->NitroNews->SelectArticle(9));
	}
}
?>
Return current item: OpenNitro