diff --git a/.gitignore b/.gitignore index 11fd4ad..e3fbd20 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /.buildpath /.project .~* +/nbproject/private/ \ No newline at end of file diff --git a/application/layouts/scripts/common/frontend/components/content_with_moduleListing.tpl b/application/layouts/scripts/common/frontend/components/content_with_moduleListing.tpl new file mode 100644 index 0000000..a56212a --- /dev/null +++ b/application/layouts/scripts/common/frontend/components/content_with_moduleListing.tpl @@ -0,0 +1,5 @@ +{block name="share"}{component shareWidget}{/block} +{block name="top"}{/block} +{block name="leftModuleListing"}{component moduleList id="left"}{/block} +
{block name="body"}{/block}
+{block name="comments"}{/block} \ No newline at end of file diff --git a/application/views/scripts/governing/article.tpl b/application/views/scripts/governing/article.tpl new file mode 100644 index 0000000..26b2d4c --- /dev/null +++ b/application/views/scripts/governing/article.tpl @@ -0,0 +1,17 @@ +

{$section.displayTitle} {component shareWidget}

+{$content.displayTitle} +

{$content.subTitle}

+

{$content.title}

+{component byline} | {$content.publishDate} +{compontent embeddedGallery} +
+ + {media width=150} +
+ Photo by {$content.mainImage.author} +
+
+ {component voteWidget} +
+
{$content.body}
+ diff --git a/application/views/scripts/governing/components/share.tpl b/application/views/scripts/governing/components/share.tpl new file mode 100644 index 0000000..1c40175 --- /dev/null +++ b/application/views/scripts/governing/components/share.tpl @@ -0,0 +1,21 @@ +
+ + + +
+ + + + + + + + | + More +
+ + +
\ No newline at end of file diff --git a/application/views/scripts/governing/components/vote.tpl b/application/views/scripts/governing/components/vote.tpl new file mode 100644 index 0000000..c580f68 --- /dev/null +++ b/application/views/scripts/governing/components/vote.tpl @@ -0,0 +1,18 @@ +
+
+ + + + +
+
+ + + + +
+ +
+ 0 + 0 votes +
\ No newline at end of file diff --git a/application/views/scripts/govtech/detail/article.tpl b/application/views/scripts/govtech/detail/article.tpl deleted file mode 100644 index ca0adef..0000000 --- a/application/views/scripts/govtech/detail/article.tpl +++ /dev/null @@ -1,16 +0,0 @@ -{foreach from=$list item=item} -
  • - - {if $item.mainImage}{image src=$item.mainImage width=150}{/if} -
    - Photo by {$item.mainImage.author} -
    -

    {$item.title}

    -

    - {$item.publishDate} - {byline src=$item} -

    -
    {$item.body}
    - {socialMedia} -
  • -{/foreach} \ No newline at end of file diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..98ea759 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,16 @@ +file.reference.php-PHPUnit=../../../usr/share/php/PHPUnit +include.path=\ + ${php.global.include.path}:\ + ${file.reference.php-PHPUnit} +php.version=PHP_5 +phpunit.bootstrap=test/bootstrap.php +phpunit.bootstrap.create.tests=true +phpunit.configuration=test/configuration.xml +phpunit.run.test.files=true +phpunit.suite= +source.encoding=UTF-8 +src.dir=. +tags.asp=false +tags.short=true +test.src.dir=test +web.root=. diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..fef60be --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,9 @@ + + + org.netbeans.modules.php.project + + + docu-zend + + + diff --git a/test/application/controllers/IndexControllerTest.php b/test/application/controllers/IndexControllerTest.php new file mode 100644 index 0000000..248f6d8 --- /dev/null +++ b/test/application/controllers/IndexControllerTest.php @@ -0,0 +1,30 @@ +bootstrap = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini'); + parent::setUp(); + } + + public function testIndexAction() + { + $params = array('action' => 'index', 'controller' => 'Index', 'module' => 'default'); + $urlParams = $this->urlizeOptions($params); + $url = $this->url($urlParams); + $this->dispatch($url); + + // assertions + $this->assertModule($urlParams['module']); + $this->assertController($urlParams['controller']); + $this->assertAction($urlParams['action']); + $this->assertQueryContentContains("div#welcome h3", "This is your project's main page"); + } + + +} + + + diff --git a/test/application/models/ArticleTest.php b/test/application/models/ArticleTest.php new file mode 100644 index 0000000..c9548ea --- /dev/null +++ b/test/application/models/ArticleTest.php @@ -0,0 +1,34 @@ +object = new Article; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() { + + } + +} + +?> diff --git a/test/application/models/SectionTest.php b/test/application/models/SectionTest.php new file mode 100644 index 0000000..5dd8847 --- /dev/null +++ b/test/application/models/SectionTest.php @@ -0,0 +1,298 @@ +__construct + * Tests the ability to create new sections. + */ + public function testCanCreateSection() { + $section = new Section("/foo", "Some Section"); + $this->assertEquals("/foo", $section->getPath()); + $this->assertEquals("Some Section", $section->getTitle()); + } + + /** + * @covers $section->__construct + * Tests the prevention of orphan section creation + */ + public function testCannotCreateOrphanSection() { + try { + $section = new Section("/bad/path", "Bad Section"); + $section = $this->getMock("Section", array('getParent'), array("/bad/path", "Bad Section")); + $section->expects($this->any()) + ->method('getParent') + ->will($this->returnValue(false)); + } catch (Exception $e) { + $this->assertEquals("Invalid parent set", $e->getMessage()); + return; + } + $this->fail("Exception expected"); + } + + /* + * @covers @section->_construct + * Tests the prevention of bad paths + */ + public function testCanDetectInvalidPaths() { + try { + $section = new Section("?bad?section"); + } catch (Exception $e) { + $this->assertEquals("Invalid path set", $e->getMessage()); + return; + } + + } + + /** + * @covers $section->__construct + * Tests the ability to retrieve sections + */ + public function testCanRetrieveSection() { + // Get root + $section = new Section("/"); + $this->assertNotEmpty($section->site); + $this->assertEquals(1, $section->_id); + + // Get subsection by path + $section = new Section("/topics"); + $this->assertNotEmpty($this->site, $section); + $this->assertEquals(2, $section->_id); + + // Get subsection by title + $section = new Section("topics"); + $this->assertNotEmpty($this->site, $section); + $this->assertEquals(3, $section->_id); + } + + /** + * @covers $section->getPath() + * @todo Implement testGetPath(). + */ + public function testGetPath() { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers $section->getSegmentedPath() + * @todo Implement testGetSegmentedPath(). + */ + public function testGetSegmentedPath() { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers $section->getParent() + * Expected return: Section + * @todo Implement testGetParent(). + */ + public function testGetParent() { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers $section->getContentList() + * @todo Implement testGetContentList(). + */ + public function testGetContentList() { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers $section->getContent() + * @todo Implement testGetContent(). + */ + public function testGetContent() { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers $section->setMainTemplate() + * Tests the ability to set main template + */ + public function testCanSetMainTemplate1() { + $section = new Section("bare_section"); + $this->assertEmpty($section->getMainTemplate()); + + $section->setMainTemplate('listing/template.tpl'); + $this->assertEquals("listing/template", $section->getMainTemplate()); + //$this->assertNotEmpty($section->templates['main']->_id); + //$section->Commit(); + //Assert records exist + + } + + /** + * @covers $section->setDetailTemplate() + * Tests the ability to set detail template + */ + public function testCanSetDetailTemplate() { + $section = new Section("bare_section"); + $section->setDetailTemplate("Article", "detail/template.tpl"); + $this->assertEquals("detail/template", $section->getDetailTemplate("Article")); + //$this->assertNotEmpty($section->getDetailTemplate("Article")->_id); + } + + public function testTemplateMustBeString() { + $section = new Section("bare_section"); + try { + $section->setDetailTemplate("Article", new StdClass()); + } catch (Exception $e) + { + $this->assert("Template must be string", $e->getMessage()); + return; + } + $this->fail("Non-string template input should not be accepted"); + } + + /** + * @covers $section->getMainTemplate() + * Tests the ability to set detail template + */ + public function testCanGetMainTemplate() { + $section = new Section("complete_section"); + $template = $section->getMainTemplate("Article"); + $this->assertNotEmpty($template); + $this->assertType("Template", $template); + } + + /** + * @covers $section->setDetailTemplate() + * Tests the ability to get detail template + */ + public function testCanGetDetailTemplate() { + $section = new Section("complete_section"); + $template = $section->getDetailTemplate("Article"); + $this->assertNotEmpty($template); + $this->assertType("Template", $template); + } + + /** + * @covers $section->getAllTemplates() + * Tests ability to retrieve ALL templates + * associated to section. + * Don't see a reason to use this on the frontend. + */ + public function testCanGetAllTemplates() { + $section = new Section("complete_section"); + $templates = $section->getAllTemplates(); + $this->assertNotEmpty($templates); + $this->assertInternalType("Array", $templates); + $this->assertType("Template", $templates[0]); + } + + /** + * @covers $section->getAllDetailTemplates() + * Tests ability to retrieve all detail templates. + * Todo: Assertion that main template doesn't show up + */ + public function testCanGetAllDetailTemplates() { + $section = new Section("complete_section"); + $templates = $section->getAllDetailTemplates(); + $this->assertNotEmpty($templates); + $this->assertInternalType("Array", $templates); + $this->assertType("Template", $templates[0]); + } + + /** + * @covers $section->getModules() + */ + public function testGetModules() { + $section = new Section("complete_section"); + $this->assertObjectHasAttribute("modules", $section); + $modules = $section->getModules("left"); + $this->assertEquals(3, $modules); + + $this->assertType("Module", $modules[0]); + } + + /** + * @covers $section->getModule() + */ + public function testGetModule() { + $section = new Section("complete_section"); + $module = $section->getModule(1245); // By _id + $this->assertNotEmpty($module); + $this->assertType("Module", $module); + + $module = $section->getModule("left", 0); // column, Order + $this->assertNotEmpty($module); + $this->assertType("Module", $module); + } + + public function testGetNonExistentModule() { + $section = new Section("complete_section"); + $module = $section->getModule(999999); // By _id + $this->assertEquals(null, $module); + + $module = $section->getModule("badcolumn", 0); // column, Order + $this->assertEquals(null, $module); + } + + /** + * @covers $section->addModule() + * Tests ability to add a module + */ + public function testCanSetModule() { + $section = new Section("bare_section"); + $section->setModule("left", new Module("Test")); + $section->setModule("left", new Module("Test 2"), 0); + $this->assertEquals(2, count($section->getModules("left"))); + $module = $section->getModule(0); + $this->assertEquals("Test", $module->title); + } + + public function testCannotSetNonModuleToModules() { + $section = new Section("bare_section"); + try { + $section->setModule("left", new Template("Test")); + } catch (Exception $e) { + $this->assertEquals("Module must be type Module", $e->getMessage()); + return; + } + $this->fail("Should not allow non-modules to be added"); + + } +} \ No newline at end of file diff --git a/test/bootstrap.php b/test/bootstrap.php new file mode 100644 index 0000000..493c49d --- /dev/null +++ b/test/bootstrap.php @@ -0,0 +1,28 @@ + + + + + + + diff --git a/test/library/erepublic/CollectionTest.php b/test/library/erepublic/CollectionTest.php new file mode 100644 index 0000000..604aea1 --- /dev/null +++ b/test/library/erepublic/CollectionTest.php @@ -0,0 +1,118 @@ +attrib1; + } +} +/** + * Test class for Collection. + * Generated by PHPUnit on 2011-12-01 at 10:36:10. + */ +class CollectionTest extends PHPUnit_Framework_TestCase { + + /** + * @var Collection + */ + protected $object; + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + protected function setUp() { + + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() { + + } + + public function testFoo() { + $collection = new Collection(); + $foo = new StdClass(); + $foo->attrib1 = "test"; + $foo->attrib2 = "test"; + $collection[] = $foo; + $this->assertEquals("test", $collection[0]->attrib1); + //$section->templates['main'] // + + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testPush(). + */ + public function testPush() { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testRewind(). + */ + public function testRewind() { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testCurrent(). + */ + public function testCurrent() { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testKey(). + */ + public function testKey() { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testNext(). + */ + public function testNext() { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testValid(). + */ + public function testValid() { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + +} + +?> diff --git a/test/phpunit.xml b/test/phpunit.xml new file mode 100644 index 0000000..75dc6ed --- /dev/null +++ b/test/phpunit.xml @@ -0,0 +1,17 @@ + + + ./application + + + ./library + + + + + + +