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 and added new test class for `…
Browse files Browse the repository at this point in the history
…`Zepto\Helper``
  • Loading branch information
hassankhan committed Feb 12, 2014
1 parent f3b469a commit fa880ec
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 120 deletions.
1 change: 1 addition & 0 deletions tests/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@

require_once realpath(__DIR__ . '/../vendor/autoload.php');

// Usually, this would be defined in ``Zepto\Zepto->container['ROOT_DIR']
defined('ROOT_DIR')
|| define('ROOT_DIR', realpath(dirname(__FILE__) . '/..') . '/');
163 changes: 163 additions & 0 deletions tests/Zepto/HelperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
<?php
namespace Zepto;

/**
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-02-12 at 20:07:01.
*/
class HelperTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Helper
*/
protected $helper;

/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
// $zepto = new Zepto;
// $this->helper = new Helper($zepto->app);
}

/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}

/**
* @covers Zepto\Helper::default_config
*/
public function testDefaultConfig()
{
$expected = 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
)
);
$this->assertEquals($expected, Helper::default_config());
}

/**
* @covers Zepto\Helper::validate_config()
*/
public function testValidateConfig()
{
ob_start();
$config = Helper::default_config();
$this->assertTrue(Helper::validate_config($config));
}

/**
* @covers Zepto\Helper::validate_config()
* @expectedException InvalidArgumentException
*/
public function testConfigWithInvalidContentDir()
{
ob_start();
$config = Helper::default_config();
$config['zepto']['content_dir'] = 'no_such_dir';
Helper::validate_config($config);
}

/**
* @covers Zepto\Helper::validate_config()
* @expectedException InvalidArgumentException
*/
public function testConfigWithInvalidPluginsDir()
{
ob_start();
$config = Helper::default_config();
$config['zepto']['plugins_dir'] = 'no_such_dir';
Helper::validate_config($config);
}

/**
* @covers Zepto\Helper::validate_config()
* @expectedException InvalidArgumentException
*/
public function testConfigWithInvalidTemplatesDir()
{
ob_start();
$config = Helper::default_config();
$config['zepto']['templates_dir'] = 'no_such_dir';
Helper::validate_config($config);
}

/**
* @covers Zepto\Helper::validate_config()
* @expectedException InvalidArgumentException
*/
public function testConfigWithInvalidDefaultTemplate()
{
ob_start();
$config = Helper::default_config();
$config['zepto']['default_template'] = 'no_such_file';
Helper::validate_config($config);
}

/**
* @covers Zepto\Helper::validate_config()
* @expectedException InvalidArgumentException
*/
public function testConfigWithInvalidSiteRoot()
{
ob_start();
$config = Helper::default_config();
$config['zepto']['environment'] = 'production';
$config['site']['site_root'] = 'fuck://this@should?fail';
Helper::validate_config($config);
}

/**
* @covers Zepto\Helper::url_for
* @todo Implement testUrl_for().
*/
public function testUrl_for()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}

/**
* @covers Zepto\Helper::link_for
* @todo Implement testLink_for().
*/
public function testLink_for()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
}

0 comments on commit fa880ec

Please sign in to comment.