From c40c2c905f4aa02fd12346b1a0527283261e8b05 Mon Sep 17 00:00:00 2001 From: Brett Bieber Date: Wed, 30 Nov 2011 14:09:18 -0600 Subject: [PATCH 1/3] Add test for adding a story --- tests/Stories/addStory.phpt | 18 ++++++++++++++++++ tests/Stories/insertStory.inc.php | 11 +++++++++++ 2 files changed, 29 insertions(+) create mode 100644 tests/Stories/addStory.phpt create mode 100644 tests/Stories/insertStory.inc.php diff --git a/tests/Stories/addStory.phpt b/tests/Stories/addStory.phpt new file mode 100644 index 00000000..7dfdb728 --- /dev/null +++ b/tests/Stories/addStory.phpt @@ -0,0 +1,18 @@ +--TEST-- +Add a story +--FILE-- + +===DONE=== +--CLEAN-- +query('DELETE FROM stories WHERE title="My big news story";'); +?> +--EXPECT-- +===DONE=== \ No newline at end of file diff --git a/tests/Stories/insertStory.inc.php b/tests/Stories/insertStory.inc.php new file mode 100644 index 00000000..117aa95b --- /dev/null +++ b/tests/Stories/insertStory.inc.php @@ -0,0 +1,11 @@ +title = "My big news story"; +$story->description = "Here's the basic info about the story"; +$story->uid_created = UNL_ENews_Controller::getUser()->uid; +$story->sponsor = "Student Affairs"; +$story->presentation_id = UNL_ENews_Story_Presentation::getDefault('news')->id; + +if (!$story->save()) { + echo 'Should have saved and it did not'; +} \ No newline at end of file From 9d3c968437fa1e6c1f3e56d742e6ac27a2807f4b Mon Sep 17 00:00:00 2001 From: Brett Bieber Date: Wed, 30 Nov 2011 14:10:01 -0600 Subject: [PATCH 2/3] Implement ->addStory test --- tests/Newsletter/addStory.phpt | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/tests/Newsletter/addStory.phpt b/tests/Newsletter/addStory.phpt index c0cbb12e..c8b40233 100644 --- a/tests/Newsletter/addStory.phpt +++ b/tests/Newsletter/addStory.phpt @@ -1,15 +1,36 @@ --TEST-- Add story to newsletter test ---SKIPIF-- -skip ---POST-- -foo=& --FILE-- newsroom_id = 1; +$newsletter->release_date = date('Y-m-d H:i:s', strtotime('tomorrow')); +$newsletter->subject = 'My big newsletter'; + +if (!$newsletter->save()) { + echo 'Should have saved and it did not'; +} + +// Now let's get a story +include __DIR__ . '/../Stories/insertStory.inc.php'; + +if (!$newsletter->addStory($story)) { + echo 'Should have added and it did not'; +} + +if (!$newsletter->hasStory($story)) { + echo 'Newsletter should have this story and it does not'; +} ?> ===DONE=== +--CLEAN-- +query('DELETE FROM newsletters WHERE subject="My big newsletter";'); +?> --EXPECT-- ===DONE=== \ No newline at end of file From 493b6235c14076bca7ea7be5b19bbada6b2ad671 Mon Sep 17 00:00:00 2001 From: Brett Bieber Date: Thu, 22 Dec 2011 15:53:39 -0600 Subject: [PATCH 3/3] Ignore generated test coverage data --- tests/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tests/.gitignore diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 00000000..8f3ba120 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,2 @@ +*.xdebug +pear2coverage.db