aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional')
-rw-r--r--tests/functional/auth_test.php40
-rw-r--r--tests/functional/browse_test.php6
-rw-r--r--tests/functional/extension_controller_test.php9
-rw-r--r--tests/functional/fileupload_form_test.php69
-rw-r--r--tests/functional/fileupload_remote_test.php72
-rw-r--r--tests/functional/fixtures/files/empty.png0
-rw-r--r--tests/functional/fixtures/files/illegal-extension.bifbin0 -> 519 bytes
-rw-r--r--tests/functional/fixtures/files/too-large.pngbin0 -> 284717 bytes
-rw-r--r--tests/functional/fixtures/files/valid.jpgbin0 -> 554 bytes
-rw-r--r--tests/functional/lang_test.php45
10 files changed, 232 insertions, 9 deletions
diff --git a/tests/functional/auth_test.php b/tests/functional/auth_test.php
new file mode 100644
index 0000000000..e955dcb4df
--- /dev/null
+++ b/tests/functional/auth_test.php
@@ -0,0 +1,40 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @group functional
+*/
+class phpbb_functional_auth_test extends phpbb_functional_test_case
+{
+ public function test_login()
+ {
+ $this->login();
+
+ // check for logout link
+ $crawler = $this->request('GET', 'index.php');
+ $this->assertContains($this->lang('LOGOUT_USER', 'admin'), $crawler->filter('.navbar')->text());
+ }
+
+ /**
+ * @depends test_login
+ */
+ public function test_logout()
+ {
+ $this->login();
+ $this->add_lang('ucp');
+
+ // logout
+ $crawler = $this->request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout');
+ $this->assertContains($this->lang('LOGOUT_REDIRECT'), $crawler->filter('#message')->text());
+
+ // look for a register link, which should be visible only when logged out
+ $crawler = $this->request('GET', 'index.php');
+ $this->assertContains($this->lang('REGISTER'), $crawler->filter('.navbar')->text());
+ }
+}
diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php
index 723cf93232..26c18c4c1f 100644
--- a/tests/functional/browse_test.php
+++ b/tests/functional/browse_test.php
@@ -23,4 +23,10 @@ class phpbb_functional_browse_test extends phpbb_functional_test_case
$crawler = $this->request('GET', 'viewforum.php?f=2');
$this->assertGreaterThan(0, $crawler->filter('.topiclist')->count());
}
+
+ public function test_viewtopic()
+ {
+ $crawler = $this->request('GET', 'viewtopic.php?t=1');
+ $this->assertGreaterThan(0, $crawler->filter('.postbody')->count());
+ }
}
diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php
index 4ee0e68718..e9409d9d3f 100644
--- a/tests/functional/extension_controller_test.php
+++ b/tests/functional/extension_controller_test.php
@@ -65,15 +65,6 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
}
}
- public static function tearDownAfterClass()
- {
- $phpbb_root_path = self::$config['phpbb_functional_path'];
-
- // @todo delete the fixtures from the $phpbb_root_path board
- // Note that it might be best to find a public domain function
- // and port it into here instead of writing it from scratch
- }
-
public function setUp()
{
parent::setUp();
diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php
new file mode 100644
index 0000000000..f7267fa659
--- /dev/null
+++ b/tests/functional/fileupload_form_test.php
@@ -0,0 +1,69 @@
+<?php
+/**
+ *
+ * @package testing
+ * @copyright (c) 2012 phpBB Group
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+ *
+ */
+
+/**
+ * @group functional
+ */
+class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
+{
+ private $path;
+
+ public function setUp()
+ {
+ parent::setUp();
+ $this->path = __DIR__ . '/fixtures/files/';
+ $this->add_lang('posting');
+ $this->login();
+ }
+
+ private function upload_file($filename, $mimetype)
+ {
+ $file = array(
+ 'tmp_name' => $this->path . $filename,
+ 'name' => $filename,
+ 'type' => $mimetype,
+ 'size' => filesize($this->path . $filename),
+ 'error' => UPLOAD_ERR_OK,
+ );
+
+ $crawler = $this->client->request(
+ 'POST',
+ 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid,
+ array('add_file' => $this->lang('ADD_FILE')),
+ array('fileupload' => $file)
+ );
+
+ return $crawler;
+ }
+
+ public function test_empty_file()
+ {
+ $crawler = $this->upload_file('empty.png', 'image/png');
+ $this->assertEquals($this->lang('ATTACHED_IMAGE_NOT_IMAGE'), $crawler->filter('div#message p')->text());
+ }
+
+ public function test_invalid_extension()
+ {
+ $crawler = $this->upload_file('illegal-extension.bif', 'application/octet-stream');
+ $this->assertEquals($this->lang('DISALLOWED_EXTENSION', 'bif'), $crawler->filter('p.error')->text());
+ }
+
+ public function test_too_large()
+ {
+ $this->markTestIncomplete('Functional tests use an admin account which ignores maximum upload size.');
+ $crawler = $this->upload_file('too-large.png', 'image/png');
+ $this->assertEquals($this->lang('WRONG_FILESIZE', '256', 'KiB'), $crawler->filter('p.error')->text());
+ }
+
+ public function test_valid_file()
+ {
+ $crawler = $this->upload_file('valid.jpg', 'image/jpeg');
+ $this->assertContains($this->lang('POSTED_ATTACHMENTS'), $crawler->filter('#postform h3')->eq(1)->text());
+ }
+}
diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php
new file mode 100644
index 0000000000..0deb79acf6
--- /dev/null
+++ b/tests/functional/fileupload_remote_test.php
@@ -0,0 +1,72 @@
+<?php
+/**
+ *
+ * @package testing
+ * @copyright (c) 2012 phpBB Group
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+ *
+ */
+
+/**
+ * @group functional
+ */
+class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
+{
+ public function setUp()
+ {
+ parent::setUp();
+ // Only doing this within the functional framework because we need a
+ // URL
+
+ // Global $config required by unique_id
+ // Global $user required by fileupload::remote_upload
+ global $config, $user;
+
+ if (!is_array($config))
+ {
+ $config = array();
+ }
+
+ $config['rand_seed'] = '';
+ $config['rand_seed_last_update'] = time() + 600;
+
+ $user = new phpbb_mock_user();
+ $user->lang = new phpbb_mock_lang();
+ }
+
+ public function tearDown()
+ {
+ global $config, $user;
+ $user = null;
+ $config = array();
+ }
+
+ public function test_invalid_extension()
+ {
+ $upload = new fileupload('', array('jpg'), 100);
+ $file = $upload->remote_upload('http://example.com/image.gif');
+ $this->assertEquals('URL_INVALID', $file->error[0]);
+ }
+
+ public function test_non_existant()
+ {
+ $upload = new fileupload('', array('jpg'), 100);
+ $file = $upload->remote_upload('http://example.com/image.jpg');
+ $this->assertEquals('EMPTY_REMOTE_DATA', $file->error[0]);
+ }
+
+ public function test_successful_upload()
+ {
+ $upload = new fileupload('', array('gif'), 1000);
+ $file = $upload->remote_upload($this->root_url . 'styles/prosilver/theme/images/forum_read.gif');
+ $this->assertEquals(0, sizeof($file->error));
+ $this->assertTrue(file_exists($file->filename));
+ }
+
+ public function test_too_large()
+ {
+ $upload = new fileupload('', array('gif'), 100);
+ $file = $upload->remote_upload($this->root_url . 'styles/prosilver/theme/images/forum_read.gif');
+ $this->assertEquals('WRONG_FILESIZE', $file->error[0]);
+ }
+}
diff --git a/tests/functional/fixtures/files/empty.png b/tests/functional/fixtures/files/empty.png
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/functional/fixtures/files/empty.png
diff --git a/tests/functional/fixtures/files/illegal-extension.bif b/tests/functional/fixtures/files/illegal-extension.bif
new file mode 100644
index 0000000000..3cd5038e38
--- /dev/null
+++ b/tests/functional/fixtures/files/illegal-extension.bif
Binary files differ
diff --git a/tests/functional/fixtures/files/too-large.png b/tests/functional/fixtures/files/too-large.png
new file mode 100644
index 0000000000..ed4b0abd80
--- /dev/null
+++ b/tests/functional/fixtures/files/too-large.png
Binary files differ
diff --git a/tests/functional/fixtures/files/valid.jpg b/tests/functional/fixtures/files/valid.jpg
new file mode 100644
index 0000000000..95a87ddbdf
--- /dev/null
+++ b/tests/functional/fixtures/files/valid.jpg
Binary files differ
diff --git a/tests/functional/lang_test.php b/tests/functional/lang_test.php
new file mode 100644
index 0000000000..053806a431
--- /dev/null
+++ b/tests/functional/lang_test.php
@@ -0,0 +1,45 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @group functional
+*/
+class phpbb_functional_lang_test extends phpbb_functional_test_case
+{
+ public function test_lang()
+ {
+ // Test a language string present in the common language file
+ $this->assertEquals('Board index', $this->lang('FORUM_INDEX'));
+ }
+
+ /**
+ * @expectedException RuntimeException
+ */
+ public function test_lang_missing()
+ {
+ $this->assertEquals('Your account has now been activated. Thank you for registering.', $this->lang('ACCOUNT_ACTIVE'));
+ }
+
+ public function test_add_lang()
+ {
+ $this->add_lang('ucp');
+
+ // Test a language string present only in the UCP language file
+ $this->assertEquals('Your account has now been activated. Thank you for registering.', $this->lang('ACCOUNT_ACTIVE'));
+ }
+
+ public function test_add_langs()
+ {
+ $this->add_lang(array('groups', 'memberlist'));
+
+ // Test a language string from each UCP and memberlist
+ $this->assertEquals('The selected group is already your default group.', $this->lang('ALREADY_DEFAULT_GROUP'));
+ $this->assertEquals('Profile', $this->lang('ABOUT_USER'));
+ }
+}