Index: pageroute.testframework.test
===================================================================
RCS file: pageroute.testframework.test
diff -N pageroute.testframework.test
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ pageroute.testframework.test	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,274 @@
+<?php
+// $Id$
+/**
+ * @file
+ * Pageroute Simpletest test cases
+ */
+
+/**
+ * PagerouteTestCase is a little class that simplifies testing pageroute tests
+ */
+abstract class PagerouteTestCase extends DrupalWebTestCase {
+  protected $user = NULL;
+
+  function setUp() {
+    parent::setUp("pageroute", "pageroute_ui");
+  }
+
+  function useAdmin() {
+    $user = $this->drupalCreateUser(array('administer pageroutes', 'administer nodes'));
+    $this->drupalLogin($user);
+    $this->drupalGet('admin/build/pageroute');
+    $this->assertText('Pageroute', "Make sure browser is on the Pageroute site.");
+  }
+
+  function importPageRoutes($route) {
+    $route_prid = db_last_insert_id('pageroute_routes', 'prid');
+    $this->drupalGet('admin/build/pageroute');
+    $this->clicklink('Import');
+    $edit = array('import' => $route);
+    $this->drupalPost('admin/build/pageroute/import', $edit, 'Import');
+    eval('$route_array = ' . $route . ';');
+    $this->assertText($route_array['path'], 'Make sure the pageroute ' . $route_array['path'] . ' was imported.');
+    return $route_prid;
+  }
+}
+
+/**
+ * PageRoutePageTypesTestCase tests the standard core page types from Pageroute.
+ */
+class PageRoutePageTypesTestCase extends PagerouteTestCase {
+  private $routeId;
+
+  public static function getInfo() {
+    return array(
+      'name' => t('Page types test'),
+      'description' => t('Tests all default page types.'),
+      'group' => t('PageRoute'),
+    );
+  }
+
+  function setUp() {
+    parent::setUp();
+    $route1 = "array (
+			'options' =>
+			array (
+  	    'tabs' => '2',
+				'access' =>
+				array (
+					'allowed_roles' =>
+					array (
+						1 => 1,
+						2 => 2,
+						3 => 3,
+					),
+				),
+				'redirect_path' => '',
+				'no_messages' => 1,
+			),
+			'pages' =>
+			array (
+				0 =>
+				array (
+					'name' => 'p1',
+					'module' => 'pageroute',
+					'type' => 'view',
+					'title' => 'Page 1 - Simple Node',
+					'options' =>
+					array (
+						'activated' => 1,
+						'no_tab' => 0,
+						'forward' => 'Forward',
+						'back' => 'Back',
+						'cancel' => '',
+						'nid' => '1',
+					),
+					'weight' => '-10',
+				),
+				1 =>
+				array (
+					'name' => 'p2',
+					'module' => 'pageroute',
+					'type' => 'useredit',
+					'title' => 'Page 2 - Edit User',
+					'options' =>
+					array (
+						'activated' => 1,
+						'forward' => 'Forward',
+						'back' => 'Back',
+						'cancel' => '',
+						'category' => 'account',
+					),
+					'weight' => '-10',
+				),
+				2 =>
+				array (
+					'name' => 'p3',
+					'module' => 'pageroute',
+					'type' => 'edit',
+					'title' => 'Page 3 - Node Editing(Page)',
+					'options' =>
+					array (
+						'activated' => 1,
+						'no_tab' => 0,
+						'forward' => 'Forward',
+            'back' => 'Back',
+            'cancel' => '',
+            'content-type' => 'page',
+            'preview' => 1,
+            'submit' => 1,
+            'nodelete' => 1,
+					),
+					'weight' => '-10',
+				),
+				3 =>
+				array (
+          'name' => 'p4',
+          'module' => 'pageroute',
+          'type' => 'add',
+          'title' => 'Page 4 - Node adding(blog)',
+          'options' =>
+          array (
+            'activated' => 1,
+            'no_tab' => 0,
+            'forward' => 'Forward',
+            'back' => 'Back',
+            'cancel' => 'Cancel',
+            'content-type' => 'blog',
+            'preview' => 0,
+            'submit' => 1,
+          ),
+          'weight' => '-10',
+        ),
+        4 =>
+        array (
+          'name' => 'p5',
+          'module' => 'pageroute',
+          'type' => 'manage',
+          'title' => 'Page 5 - Node Managment(Poll)',
+          'options' =>
+          array (
+            'activated' => 1,
+            'no_tab' => 0,
+            'forward' => 'Forward',
+            'back' => 'Back',
+            'cancel' => '',
+            'content-type' => 'poll',
+            'add_button' => 'Add',
+            'empty' =>
+            array (
+              'force_add' => '0',
+              'cancel' => 'Cancel',
+              'add_button' => 'Add',
+            ),
+            'add' =>
+            array (
+              'forward' => 'Forward',
+              'back' => 'Back',
+              'cancel' => 'Cancel',
+              'preview' => 0,
+              'submit' => 1,
+            ),
+            'edit' =>
+            array (
+              'forward' => 'Forward',
+              'back' => 'Back',
+              'cancel' => 'Cancel',
+              'preview' => 0,
+              'submit' => 1,
+              'nodelete' => 1,
+						),
+          ),
+          'weight' => '-10',
+				),
+			),
+      'page_index' =>
+      array (
+        'p1' => 0,
+        'p2' => 1,
+        'p3' => 2,
+        'p4' => 3,
+        'p5' => 4,
+      ),
+      'page_access' =>
+      array (
+      ),
+      'path' => 'pageroute1',
+      'page_data_current' => NULL,
+      'page_data_previous' => NULL,
+		)";
+
+    $this->useAdmin();
+    $node = array(
+      'body' => $this->randomName(32),
+      'title' => $this->randomName(8),
+    );
+    $this->drupalCreateNode($node);
+    $this->routeId = $this->importPageRoutes($route1);
+  }
+
+  function testingNodeDisplay() {
+    $this->drupalGet('pageroute1/p1//');
+    $this->assertText('Page 1');
+    $this->drupalPost('pageroute1/p1//', NULL, 'Forward');
+    $this->assertText('Page 2');
+  }
+
+  function testingEditUser() {
+    $this->drupalGet('pageroute1/p2//');
+    $this->assertText('Page 2');
+    $this->drupalPost('pageroute1/p2//', NULL, 'Back');
+    $this->assertText('Page 1');
+  }
+
+  function testingNodeEditing() {
+    $this->drupalGet('pageroute1/p3//');
+    $this->assertText('Page 3');
+  }
+
+  function testingNodeAdding() {
+    $this->drupalGet('pageroute1/p4//');
+    $this->assertText('Page 4');
+  }
+
+  function testingNodeManagment() {
+    $this->drupalGet('pageroute1/p5//');
+    $this->assertText('Page 5');
+  }
+
+  function testingPage1Edit() {
+    $this->drupalGet('admin/build/pageroute/' . $this->routeId . '/page-edit/p1');
+    file_put_contents('/home/sebastian/output/output.html', $this->drupalGetContent());
+    $this->assertText('p1');
+  }
+
+  function testingPage2Edit() {
+    $this->drupalGet('admin/build/pageroute/' . $this->routeId . '/page-edit/p2');
+    $this->assertText('p2');
+  }
+
+  function testingPage3Edit() {
+    $this->drupalGet('admin/build/pageroute/' . $this->routeId . '/page-edit/p3');
+    $this->assertText('p3');
+  }
+
+  function testingPage4Edit() {
+    $this->drupalGet('admin/build/pageroute/' . $this->routeId . '/page-edit/p4');
+    $this->assertText('p4');
+  }
+
+  function testingPage5Edit() {
+    $this->drupalGet('admin/build/pageroute/' . $this->routeId . '/page-edit/p5');
+    $this->assertText('p5');
+  }
+
+  function testingEditRoute() {
+    $this->drupalGet('admin/build/pageroute/' . $this->routeId . '/edit');
+    $this->assertText('Edit route');
+  }
+
+  function testingAddPage() {
+    $this->drupalGet('admin/build/pageroute/' . $this->routeId . '/add');
+    $this->assertText('Choose a page type:');
+  }
+}
