summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThe Great Git Migration2008-09-05 22:20:07 (GMT)
committer The Great Git Migration2008-09-05 22:20:07 (GMT)
commitff12754c11e5fe6167b90c82437aeae422c2e3e6 (patch)
tree101636b3f6022f96eac500b9ea73e121e42a32cd
parent0f3d6b93318b69a22b09c4c14c2d4018431f1b8d (diff)
This commit was manufactured as part of Drupal's Great Git Migration to
create branch 'DRUPAL-6--1'. Cherrypick from master 2008-09-05 22:20:06 UTC Jeff Miccolis <jeff@miccolis.net> 'Update context_ui test to work with newer simpletest module. Simplified test a bit as the testing of setting a context needs to be reworked.': context.info context_ui/context_ui.info context_ui/tests/context_ui.test tests/context.test
-rw-r--r--context.info5
-rw-r--r--context_ui/context_ui.info6
-rw-r--r--context_ui/tests/context_ui.test51
-rw-r--r--tests/context.test95
4 files changed, 157 insertions, 0 deletions
diff --git a/context.info b/context.info
new file mode 100644
index 0000000..0585533
--- /dev/null
+++ b/context.info
@@ -0,0 +1,5 @@
+; $Id$
+name = Context
+description = "Provide modules with a cache that lasts for a single page request."
+package = Context
+core = "6.x" \ No newline at end of file
diff --git a/context_ui/context_ui.info b/context_ui/context_ui.info
new file mode 100644
index 0000000..0a378e1
--- /dev/null
+++ b/context_ui/context_ui.info
@@ -0,0 +1,6 @@
+; $Id$
+name = Context UI
+description = "Provides a simple UI for settings up a site structure using Context."
+dependencies[] = context
+package = Context
+core = "6.x" \ No newline at end of file
diff --git a/context_ui/tests/context_ui.test b/context_ui/tests/context_ui.test
new file mode 100644
index 0000000..5f944c9
--- /dev/null
+++ b/context_ui/tests/context_ui.test
@@ -0,0 +1,51 @@
+<?php
+// $Id$
+
+/**
+ * Functional Test for Context UI
+ *
+ * TODO Test if menu and blocks respond.
+ */
+
+class ContextUiTestCase extends DrupalWebTestCase {
+
+ function getInfo() {
+ return array(
+ 'name' => t('Context UI functional tests'),
+ 'description' => t('Create and save a context.') ,
+ 'group' => t('Context UI'),
+ );
+ }
+
+ function setUp() {
+ parent::setUp('context', 'context_ui');
+
+ // Create and login user
+ $admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer blocks', 'access content', 'create page content'));
+ $this->drupalLogin($admin_user);
+ }
+
+ function tearDown() {
+ parent::tearDown();
+ }
+
+ function testCreateContext() {
+ // Create context
+ $context = new stdClass();
+ $context->namespace = strtolower($this->randomName(15));
+ $context->attribute = strtolower($this->randomName(15));
+ $context->value = strtolower($this->randomName(15));
+ $this->context = $context;
+
+ $edit = array(
+ 'namespace' => $context->namespace,
+ 'attribute' => $context->attribute,
+ 'value' => $context->value,
+ 'items[node][page]' => 'page',
+ 'items[menu]' => 'node/add/page',
+ );
+ $this->drupalPost('admin/build/context/add', $edit, 'Save');
+ $this->assertRaw(t('The context %title was saved successfully.', array('%title' => $edit['value'])), 'Context saved.');
+
+ }
+}
diff --git a/tests/context.test b/tests/context.test
new file mode 100644
index 0000000..c1638ce
--- /dev/null
+++ b/tests/context.test
@@ -0,0 +1,95 @@
+<?php
+// $Id$
+
+class ContextUnitTestCase extends DrupalWebTestCase {
+ /**
+ * Implementation of get_info() for information
+ */
+ function getInfo() {
+ return array(
+ 'name' => t('context_get(), context_exists() unit tests'),
+ 'description' => t('Sets all possible context types and checks for integrity.') ,
+ 'group' => t('Context'),
+ );
+ }
+
+ function setUp() {
+ return;
+ }
+
+ function tearDown() {
+ return;
+ }
+
+ function testContextGet() {
+ // define possible data types
+ $set_types = array(
+ 'bool' => true,
+ 'int' => 1,
+ 'string' => 'lorem',
+ 'array' => array('lorem'),
+ 'object' => new StdClass(),
+ );
+ $id_types = array('int', 'string');
+
+ // NAMESPACE
+ foreach ($set_types as $type => $val) {
+ $set = context_set($val);
+ // Test return value of context_set()
+ if (in_array($type, $id_types)) {
+ // test set integrity
+ $this->assertIdentical(true, $set, 'Space set successful.');
+ // test get integrity
+ $this->assertIdentical(array(), context_get($val), 'Namespace get successful.');
+ $this->assertIdentical(true, context_exists($val), 'Namespace exists successful.');
+ }
+ else {
+ $this->assertIdentical(false, $set, 'Prohibited namespace not established.');
+ }
+ context_clear();
+ }
+
+ // NAMESPACE+ATTRIBUTE
+ foreach ($set_types as $type => $val) {
+ foreach ($set_types as $type2 => $val2) {
+ // test set integrity
+ $set = context_set($val, $val2);
+ if (in_array($type, $id_types)) {
+ // test set integrity
+ if ($type2 != 'bool') {
+ $this->assertIdentical(true, $set, 'Namespace and attribute set successful.');
+ }
+ else {
+ $this->assertIdentical(false, $set);
+ }
+ // test get + exists integrity
+ if (in_array($type2, $id_types)) {
+ $this->assertIdentical(true, (context_get($val, $val2) == $val2), 'Namespace and attribute get successful.');
+ $this->assertIdentical(true, context_exists($val, $val2), 'Namespace and attribute exists.');
+ }
+ else if (in_array($type2, array('array', 'object'))) {
+ $this->assertIdentical(true, (context_get($val) == $val2), 'Namespace and attribute get successful.');
+ $this->assertIdentical(true, context_exists($val), 'Namespace and attribute exists.');
+ }
+ }
+ }
+ context_clear();
+ }
+
+ // NAMESPACE+ATTRIBUTE+VALUE, o lord
+ foreach ($set_types as $type => $val) {
+ foreach ($set_types as $type2 => $val2) {
+ foreach ($set_types as $type3 => $val3) {
+ $set = context_set($val, $val2, $val3);
+ if (in_array($type, $id_types)) {
+ if(in_array($type2, $id_types)) {
+ $this->assertIdentical(true, (context_get($val, $val2, $val3) == $val3), 'Namespace, attribute and value get successful.');
+ $this->assertIdentical(true, context_exists($val, $val2, $val3), 'Namespace, attribute and value exists.');
+ }
+ }
+ context_clear();
+ }
+ }
+ }
+ }
+}