Skip to content
This repository has been archived by the owner on Nov 2, 2018. It is now read-only.

Commit

Permalink
Updated test class for Zepto\Zepto
Browse files Browse the repository at this point in the history
  • Loading branch information
hassankhan committed Feb 12, 2014
1 parent e792ce7 commit 42945a8
Showing 1 changed file with 63 additions and 8 deletions.
71 changes: 63 additions & 8 deletions tests/Zepto/ZeptoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ZeptoTest extends \PHPUnit_Framework_TestCase
*/
protected function setUp()
{
// Set superglobals to define application state
$_SERVER['DOCUMENT_ROOT'] = '/var/www';
$_SERVER['SCRIPT_FILENAME'] = '/var/www/zepto/index.php';
$_SERVER['SERVER_NAME'] = 'zepto';
Expand All @@ -26,10 +27,6 @@ protected function setUp()
$_SERVER['HTTPS'] = '';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
unset($_SERVER['CONTENT_TYPE'], $_SERVER['CONTENT_LENGTH']);

// Change this to a dataprovider
include ROOT_DIR . 'config.php';
$this->config = $config;
}

/**
Expand Down Expand Up @@ -165,12 +162,12 @@ public function testLoadPlugins()

/**
* @covers Zepto\Zepto::load_plugins()
* @dataProvider providerConfig
*/
public function testLoadPluginsWhenDisabled()
public function testLoadPluginsWhenDisabled($config)
{
ob_start();
// Add assertion to check if plugins_enabled is true or not
$config = Helper::default_config();
$config['zepto']['plugins_enabled'] = false;
$zepto = new Zepto($config);
$this->assertArrayNotHasKey('plugins', $zepto->app);
Expand Down Expand Up @@ -231,15 +228,73 @@ public function testRunHooks()

/**
* @covers Zepto\Zepto::run_hooks
* @dataProvider providerConfig
*/
public function testRunHooksReturnsFalseWhenPluginsAreDisabled()
public function testRunHooksReturnsFalseWhenPluginsAreDisabled($config)
{
ob_start();
$config = Helper::default_config();
$config['zepto']['plugins_enabled'] = false;
$zepto = new Zepto($config);
$this->assertFalse($zepto->run_hooks('before_response_send'));
ob_end_clean();
}

/**
* @covers Zepto\Zepto::instance()
* @runInSeparateProcess
*/
public function testInstanceBeforeInitialization()
{
$this->assertNull(Zepto::instance());
// $this->markTestIncomplete('Not yet implemented');
}

/**
* @covers Zepto\Zepto::instance()
* @runInSeparateProcess
*/
public function testInstanceAfterInitialization()
{
$zepto = new Zepto();
$this->assertInstanceOf('Zepto\Zepto', Zepto::instance());
// $this->markTestIncomplete('Not yet implemented');
}

public function providerConfig()
{
return array(
array(
array(
'zepto' => array(
'environment' => 'dev',
'content_dir' => 'content',
'plugins_dir' => 'plugins',
'templates_dir' => 'templates',
'default_template' => 'base.twig',
'content_ext' => array('.md', '.markdown'),
'plugins_enabled' => true
),
'site' => array(
'site_root' => 'http://localhost:8888/zepto/',
'site_title' => 'Zepto',
'date_format' => 'jS M Y',
'excerpt_length' => '50',
'nav' => array(
'class' => 'nav',
'dropdown_li_class' => 'dropdown',
'dropdown_ul_class' => 'dropdown-menu'
)
),
'twig' => array(
'charset' => 'utf-8',
'cache' => 'cache',
'strict_variables' => false,
'autoescape' => false,
'auto_reload' => true
)
)
)
);
}

}

0 comments on commit 42945a8

Please sign in to comment.