Loading features/ns_article/ns_article.test +0 −4 Changes for features/ns_article/ns_article.test: 0 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -172,9 +172,5 @@ class NSArticleTest extends NodeStreamWebTestCase { } } } private function loremIpsum() { return 'Cupcake ipsum dolor sit. Amet icing bear claw gingerbread cake danish. Fruitcake cookie bear claw danish. Pie topping gummi bears candy biscuit gingerbread carrot cake topping. Jelly-o pastry lemon drops. Marshmallow jelly-o chocolate bar sugar plum bonbon halvah fruitcake. Liquorice dragée croissant chocolate tart tiramisu lollipop. Soufflé pudding liquorice lemon drops. Brownie gummi bears tart oat cake bonbon tiramisu. Faworki toffee liquorice jelly-o. Marzipan tiramisu cake jelly-o cheesecake. Cake pastry brownie powder chupa chups. Pie dessert cake pie ice cream sugar plum marzipan icing.'; } } features/ns_fact/ns_fact.test +120 −52 Changes for features/ns_fact/ns_fact.test: 120 added lines, 52 removed lines. Original line number Diff line number Diff line <?php class NSFactTest extends NodeStreamWebTestCase { public static function getInfo() { return array( 'name' => 'Fact tests', Loading @@ -10,28 +11,135 @@ class NSFactTest extends NodeStreamWebTestCase { } function setUp() { parent::setUp('ns_article', 'ns_page', 'ns_fact'); parent::setUp('ns_fact'); } /* √ testa nodtypen finns √ testa om fälten finns testa add formuläret med fälten √ testa att skapa en fact testa editformuläret med fälten testa uppdatera en fact testa ta bort en fact testa referencedialog vyn testa om fältet i ns_article och ns_page finns testa skapa article och lägga till factaruta testa skapa page och lägga till factaruta testa radera en fact som är refererad och kolla fältet på artikel om den finns kvar testa radera en fact som är refererad och kolla fältet på page om den finns kvar */ /** * Test if the the core content type poll is exists. * Test if the the core content type fact is exists and that the fields are there. */ function testNSFact() { function testNSFactBuild() { // Test if the content type exist. $types = node_type_get_types(); $this->assertTrue(isset($types['ns_fact']), t('The Fact content type exists')); $this->assertNSFactNodeForm(); } /** * Test create node. */ function testNSFactCreate() { $editor = $this->drupalCreateUser(array('access content', 'create ns_fact content', 'edit own ns_fact content', 'access content overview', 'view own unpublished content')); $this->drupalLogin($editor); $this->assertTrue(TRUE, 'Create a fact box'); $edit = array(); $edit['title'] = $this->randomName(); $edit["field_ns_fact_body[und][0][value]"] = $this->loremIpsum(); function testNSFactInArticle() { // Get all fields and make sure the fields defined are there. $this->drupalPost('node/add/ns-fact', $edit, t('Save')); $this->assertText(t('Fact @title has been created.', array('@title' => $edit['title']))); $this->assertText($edit['title']); $this->assertText($edit["field_ns_fact_body[und][0][value]"]); } /** * Test edit form of ns_fact */ function testNSFactEditForm() { $editor = $this->drupalCreateUser(array('access content', 'create ns_fact content', 'edit own ns_fact content', 'access content overview', 'view own unpublished content')); $this->drupalLogin($editor); $this->assertTrue(TRUE, 'Check the edit form'); $settings = array( 'type' => 'ns_fact', 'title' => $this->randomName(), 'field_ns_fact_body' => array(LANGUAGE_NONE => array(array('value' => $this->loremIpsum()))), ); $node = $this->drupalCreateNode($settings); $this->assertTrue(node_load($node->nid), t('Node created.')); $this->drupalGet("node/{$node->nid}/edit"); $this->assertResponse(200, t('User is allowed to edit the content.')); $this->assertText($settings['title']); $this->assertText($settings['field_ns_fact_body']['und'][0]['value']); } function testNSFactNodeDeleteForm() { $editor = $this->drupalCreateUser(array('access content', 'create ns_fact content', 'edit own ns_fact content', 'delete own ns_fact content', 'access content overview', 'view own unpublished content')); $settings = array( 'type' => 'ns_fact', 'uid' => $editor->uid, 'title' => $this->randomName(), 'field_ns_fact_body' => array(LANGUAGE_NONE => array(array('value' => $this->loremIpsum()))), ); $node = $this->drupalCreateNode($settings); $this->drupalLogin($editor); $this->drupalGet('node/' . $node->nid . '/delete'); $this->drupalPost(NULL, array(), t('Delete')); $deleted_node = node_load($node->nid, NULL, TRUE); $this->assertFalse($deleted_node, t('The node does not exist, it has been deleted.')); } public function assertNSFactNodeForm() { $fields = array( 'field_ns_fact_ns_article_fact', 'field_ns_fact_body', ); $instance = field_info_instance('node', 'field_ns_fact_ns_article_fact', 'ns_article'); // Make sure that the reference field for poll exists. $this->assertFieldsExisting($fields); // $this->assertFieldsPresent($fields); } } /* class NSArticleFactTest extends NodeStreamWebTestCase { public static function getInfo() { return array( 'name' => 'Article Fact tests', 'description' => 'Test article fact functionality.', 'group' => 'NodeStream' ); } function setUp() { parent::setUp('ns_article', 'ns_fact'); } /** * Test if the the core content type poll is exists. */ /* function testNSFactReferenceView() { $article_instance = field_info_instance('node', 'field_ns_fact_ns_article_fact', 'ns_article'); $page_instance = field_info_instance('node', 'field_ns_fact_ns_page_fact', 'ns_page'); debug($article_instance); debug($page_instance); // Make sure that the reference dialog view exists. $this->assertReferencesDialogView('ns_fact_reference_search', 'references_dialog_1', $instance); $this->assertReferencesDialogView('ns_fact_reference_search', 'references_dialog_1', $article_instance); $this->assertReferencesDialogView('ns_fact_reference_search', 'references_dialog_1', $page_instance); } /* function testNSFactInArticle() { // Create a user. $user = $this->drupalCreateUser(array('create ns_fact content', 'create ns_fact content', 'administer nodes')); // Get the form. Loading @@ -52,8 +160,8 @@ class NSFactTest extends NodeStreamWebTestCase { $saved_article_node = node_load($article->nid, NULL, TRUE); $this->assertPollTestNode($saved_article_node, $fact); // This might be not necesary(?) } private function assertReferencesDialogView($view_name, $display_name, $field_instance) { */ /* private function assertReferencesDialogView($view_name, $display_name, $field_instance) { $view = views_get_view($view_name); $this->assertTrue(isset($view), t('The view %view_name exists', array('%view_name', $view_name))); $this->assertTrue(isset($view->display[$display_name]), t('The display %display_name exists', array('%display_name' => $display_name))); Loading @@ -61,14 +169,6 @@ class NSFactTest extends NodeStreamWebTestCase { $attachable_name = $field_instance['entity_type'] . ':' . $field_instance['field_name'] . ':' . $field_instance['bundle']; $this->assertTrue(in_array($attachable_name, $display->display_options['attach']), t('The references dialog search view is attached')); } function assertFieldsExisting($fields) { $existing_fields = field_info_fields(); foreach ($fields as $field) { $this->assertTrue(isset($existing_fields[$field]), t('The field %field exists.', array('%field' => $field))); } } private function getTestArticleNode($poll = FALSE, $author = 0) { $node = array(); $node['uid'] = $author; Loading @@ -90,37 +190,5 @@ class NSFactTest extends NodeStreamWebTestCase { return $node; } private function getTestFactNode($author = 0) { $node = array(); $node['uid'] = $author; $node['type'] = 'ns_fact'; $node['title'] = $this->randomName(); $node['status'] = 1; $node['field_ns_fact_body'] = array( 'und' => array( array( 'value' => $this->loremIpsum(), ), ), ); return $node; } public function assertPollTestNode($node, $poll = FALSE) { if ($poll) { if (!is_array($poll)) { $poll = array($poll); } $entries = field_get_items('node', $node, 'field_ns_poll_ns_article_poll'); $this->assertEqual(count($entries), count($poll)); foreach ($entries as $key => $entry) { $this->assertEqual($entry['target_type'], 'node'); $this->assertEqual($entry['target_id'], $poll[$key]); } } } private function loremIpsum() { return 'Cupcake ipsum dolor sit. Amet icing bear claw gingerbread cake danish. Fruitcake cookie bear claw danish. Pie topping gummi bears candy biscuit gingerbread carrot cake topping. Jelly-o pastry lemon drops. Marshmallow jelly-o chocolate bar sugar plum bonbon halvah fruitcake. Liquorice dragée croissant chocolate tart tiramisu lollipop. Soufflé pudding liquorice lemon drops. Brownie gummi bears tart oat cake bonbon tiramisu. Faworki toffee liquorice jelly-o. Marzipan tiramisu cake jelly-o cheesecake. Cake pastry brownie powder chupa chups. Pie dessert cake pie ice cream sugar plum marzipan icing.'; } } */ No newline at end of file includes/NodeStreamWebTestCase.inc +19 −0 Changes for includes/NodeStreamWebTestCase.inc: 19 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -10,4 +10,23 @@ class NodeStreamWebTestCase extends DrupalWebTestCase { $this->profile = 'nodestream'; parent::setUp($modules); } function assertFieldsExisting($fields) { $existing_fields = field_info_fields(); foreach ($fields as $field) { $this->assertTrue(isset($existing_fields[$field]), t('The field %field exists.', array('%field' => $field))); } } function assertFieldsPresent($fields) { foreach ($fields as $field_name => $message) { $this->assertField($field_name, $message); } } function loremIpsum() { return 'Cupcake ipsum dolor sit. Amet icing bear claw gingerbread cake danish. Fruitcake cookie bear claw danish. Pie topping gummi bears candy biscuit gingerbread carrot cake topping. Jelly-o pastry lemon drops. Marshmallow jelly-o chocolate bar sugar plum bonbon halvah fruitcake. Liquorice dragée croissant chocolate tart tiramisu lollipop. Soufflé pudding liquorice lemon drops. Brownie gummi bears tart oat cake bonbon tiramisu. Faworki toffee liquorice jelly-o. Marzipan tiramisu cake jelly-o cheesecake. Cake pastry brownie powder chupa chups. Pie dessert cake pie ice cream sugar plum marzipan icing.'; } } Loading
features/ns_article/ns_article.test +0 −4 Changes for features/ns_article/ns_article.test: 0 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -172,9 +172,5 @@ class NSArticleTest extends NodeStreamWebTestCase { } } } private function loremIpsum() { return 'Cupcake ipsum dolor sit. Amet icing bear claw gingerbread cake danish. Fruitcake cookie bear claw danish. Pie topping gummi bears candy biscuit gingerbread carrot cake topping. Jelly-o pastry lemon drops. Marshmallow jelly-o chocolate bar sugar plum bonbon halvah fruitcake. Liquorice dragée croissant chocolate tart tiramisu lollipop. Soufflé pudding liquorice lemon drops. Brownie gummi bears tart oat cake bonbon tiramisu. Faworki toffee liquorice jelly-o. Marzipan tiramisu cake jelly-o cheesecake. Cake pastry brownie powder chupa chups. Pie dessert cake pie ice cream sugar plum marzipan icing.'; } }
features/ns_fact/ns_fact.test +120 −52 Changes for features/ns_fact/ns_fact.test: 120 added lines, 52 removed lines. Original line number Diff line number Diff line <?php class NSFactTest extends NodeStreamWebTestCase { public static function getInfo() { return array( 'name' => 'Fact tests', Loading @@ -10,28 +11,135 @@ class NSFactTest extends NodeStreamWebTestCase { } function setUp() { parent::setUp('ns_article', 'ns_page', 'ns_fact'); parent::setUp('ns_fact'); } /* √ testa nodtypen finns √ testa om fälten finns testa add formuläret med fälten √ testa att skapa en fact testa editformuläret med fälten testa uppdatera en fact testa ta bort en fact testa referencedialog vyn testa om fältet i ns_article och ns_page finns testa skapa article och lägga till factaruta testa skapa page och lägga till factaruta testa radera en fact som är refererad och kolla fältet på artikel om den finns kvar testa radera en fact som är refererad och kolla fältet på page om den finns kvar */ /** * Test if the the core content type poll is exists. * Test if the the core content type fact is exists and that the fields are there. */ function testNSFact() { function testNSFactBuild() { // Test if the content type exist. $types = node_type_get_types(); $this->assertTrue(isset($types['ns_fact']), t('The Fact content type exists')); $this->assertNSFactNodeForm(); } /** * Test create node. */ function testNSFactCreate() { $editor = $this->drupalCreateUser(array('access content', 'create ns_fact content', 'edit own ns_fact content', 'access content overview', 'view own unpublished content')); $this->drupalLogin($editor); $this->assertTrue(TRUE, 'Create a fact box'); $edit = array(); $edit['title'] = $this->randomName(); $edit["field_ns_fact_body[und][0][value]"] = $this->loremIpsum(); function testNSFactInArticle() { // Get all fields and make sure the fields defined are there. $this->drupalPost('node/add/ns-fact', $edit, t('Save')); $this->assertText(t('Fact @title has been created.', array('@title' => $edit['title']))); $this->assertText($edit['title']); $this->assertText($edit["field_ns_fact_body[und][0][value]"]); } /** * Test edit form of ns_fact */ function testNSFactEditForm() { $editor = $this->drupalCreateUser(array('access content', 'create ns_fact content', 'edit own ns_fact content', 'access content overview', 'view own unpublished content')); $this->drupalLogin($editor); $this->assertTrue(TRUE, 'Check the edit form'); $settings = array( 'type' => 'ns_fact', 'title' => $this->randomName(), 'field_ns_fact_body' => array(LANGUAGE_NONE => array(array('value' => $this->loremIpsum()))), ); $node = $this->drupalCreateNode($settings); $this->assertTrue(node_load($node->nid), t('Node created.')); $this->drupalGet("node/{$node->nid}/edit"); $this->assertResponse(200, t('User is allowed to edit the content.')); $this->assertText($settings['title']); $this->assertText($settings['field_ns_fact_body']['und'][0]['value']); } function testNSFactNodeDeleteForm() { $editor = $this->drupalCreateUser(array('access content', 'create ns_fact content', 'edit own ns_fact content', 'delete own ns_fact content', 'access content overview', 'view own unpublished content')); $settings = array( 'type' => 'ns_fact', 'uid' => $editor->uid, 'title' => $this->randomName(), 'field_ns_fact_body' => array(LANGUAGE_NONE => array(array('value' => $this->loremIpsum()))), ); $node = $this->drupalCreateNode($settings); $this->drupalLogin($editor); $this->drupalGet('node/' . $node->nid . '/delete'); $this->drupalPost(NULL, array(), t('Delete')); $deleted_node = node_load($node->nid, NULL, TRUE); $this->assertFalse($deleted_node, t('The node does not exist, it has been deleted.')); } public function assertNSFactNodeForm() { $fields = array( 'field_ns_fact_ns_article_fact', 'field_ns_fact_body', ); $instance = field_info_instance('node', 'field_ns_fact_ns_article_fact', 'ns_article'); // Make sure that the reference field for poll exists. $this->assertFieldsExisting($fields); // $this->assertFieldsPresent($fields); } } /* class NSArticleFactTest extends NodeStreamWebTestCase { public static function getInfo() { return array( 'name' => 'Article Fact tests', 'description' => 'Test article fact functionality.', 'group' => 'NodeStream' ); } function setUp() { parent::setUp('ns_article', 'ns_fact'); } /** * Test if the the core content type poll is exists. */ /* function testNSFactReferenceView() { $article_instance = field_info_instance('node', 'field_ns_fact_ns_article_fact', 'ns_article'); $page_instance = field_info_instance('node', 'field_ns_fact_ns_page_fact', 'ns_page'); debug($article_instance); debug($page_instance); // Make sure that the reference dialog view exists. $this->assertReferencesDialogView('ns_fact_reference_search', 'references_dialog_1', $instance); $this->assertReferencesDialogView('ns_fact_reference_search', 'references_dialog_1', $article_instance); $this->assertReferencesDialogView('ns_fact_reference_search', 'references_dialog_1', $page_instance); } /* function testNSFactInArticle() { // Create a user. $user = $this->drupalCreateUser(array('create ns_fact content', 'create ns_fact content', 'administer nodes')); // Get the form. Loading @@ -52,8 +160,8 @@ class NSFactTest extends NodeStreamWebTestCase { $saved_article_node = node_load($article->nid, NULL, TRUE); $this->assertPollTestNode($saved_article_node, $fact); // This might be not necesary(?) } private function assertReferencesDialogView($view_name, $display_name, $field_instance) { */ /* private function assertReferencesDialogView($view_name, $display_name, $field_instance) { $view = views_get_view($view_name); $this->assertTrue(isset($view), t('The view %view_name exists', array('%view_name', $view_name))); $this->assertTrue(isset($view->display[$display_name]), t('The display %display_name exists', array('%display_name' => $display_name))); Loading @@ -61,14 +169,6 @@ class NSFactTest extends NodeStreamWebTestCase { $attachable_name = $field_instance['entity_type'] . ':' . $field_instance['field_name'] . ':' . $field_instance['bundle']; $this->assertTrue(in_array($attachable_name, $display->display_options['attach']), t('The references dialog search view is attached')); } function assertFieldsExisting($fields) { $existing_fields = field_info_fields(); foreach ($fields as $field) { $this->assertTrue(isset($existing_fields[$field]), t('The field %field exists.', array('%field' => $field))); } } private function getTestArticleNode($poll = FALSE, $author = 0) { $node = array(); $node['uid'] = $author; Loading @@ -90,37 +190,5 @@ class NSFactTest extends NodeStreamWebTestCase { return $node; } private function getTestFactNode($author = 0) { $node = array(); $node['uid'] = $author; $node['type'] = 'ns_fact'; $node['title'] = $this->randomName(); $node['status'] = 1; $node['field_ns_fact_body'] = array( 'und' => array( array( 'value' => $this->loremIpsum(), ), ), ); return $node; } public function assertPollTestNode($node, $poll = FALSE) { if ($poll) { if (!is_array($poll)) { $poll = array($poll); } $entries = field_get_items('node', $node, 'field_ns_poll_ns_article_poll'); $this->assertEqual(count($entries), count($poll)); foreach ($entries as $key => $entry) { $this->assertEqual($entry['target_type'], 'node'); $this->assertEqual($entry['target_id'], $poll[$key]); } } } private function loremIpsum() { return 'Cupcake ipsum dolor sit. Amet icing bear claw gingerbread cake danish. Fruitcake cookie bear claw danish. Pie topping gummi bears candy biscuit gingerbread carrot cake topping. Jelly-o pastry lemon drops. Marshmallow jelly-o chocolate bar sugar plum bonbon halvah fruitcake. Liquorice dragée croissant chocolate tart tiramisu lollipop. Soufflé pudding liquorice lemon drops. Brownie gummi bears tart oat cake bonbon tiramisu. Faworki toffee liquorice jelly-o. Marzipan tiramisu cake jelly-o cheesecake. Cake pastry brownie powder chupa chups. Pie dessert cake pie ice cream sugar plum marzipan icing.'; } } */ No newline at end of file
includes/NodeStreamWebTestCase.inc +19 −0 Changes for includes/NodeStreamWebTestCase.inc: 19 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -10,4 +10,23 @@ class NodeStreamWebTestCase extends DrupalWebTestCase { $this->profile = 'nodestream'; parent::setUp($modules); } function assertFieldsExisting($fields) { $existing_fields = field_info_fields(); foreach ($fields as $field) { $this->assertTrue(isset($existing_fields[$field]), t('The field %field exists.', array('%field' => $field))); } } function assertFieldsPresent($fields) { foreach ($fields as $field_name => $message) { $this->assertField($field_name, $message); } } function loremIpsum() { return 'Cupcake ipsum dolor sit. Amet icing bear claw gingerbread cake danish. Fruitcake cookie bear claw danish. Pie topping gummi bears candy biscuit gingerbread carrot cake topping. Jelly-o pastry lemon drops. Marshmallow jelly-o chocolate bar sugar plum bonbon halvah fruitcake. Liquorice dragée croissant chocolate tart tiramisu lollipop. Soufflé pudding liquorice lemon drops. Brownie gummi bears tart oat cake bonbon tiramisu. Faworki toffee liquorice jelly-o. Marzipan tiramisu cake jelly-o cheesecake. Cake pastry brownie powder chupa chups. Pie dessert cake pie ice cream sugar plum marzipan icing.'; } }