Permalink
Browse files

Make Uploader test work on local machine and Travis

Signed-off-by: dchill42 <dchill42@gmail.com>
  • Loading branch information...
1 parent 155020b commit 1cebce9ea29b01e3b53685fada4e03c1a37b4501 @dchill42 committed Sep 24, 2012
Showing with 8 additions and 4 deletions.
  1. +8 −4 tests/codeigniter/libraries/Upload_test.php
@@ -107,8 +107,9 @@ function test_set_allowed_types()
function test_set_image_properties()
{
+ $dir = preg_replace('/^(.*\/tests\/).*$/', '$1', __FILE__);
$this->upload->file_type = 'image/gif';
- $this->upload->file_temp = 'mocks/uploads/ci_logo.gif';
+ $this->upload->file_temp = $dir.'mocks/uploads/ci_logo.gif';
$props = array(
'image_width' => 170,
@@ -157,7 +158,8 @@ function test_is_allowed_filetype()
$this->assertTrue($this->upload->is_allowed_filetype(FALSE));
$this->assertTrue($this->upload->is_allowed_filetype(TRUE));
- $this->upload->file_temp = 'mocks/uploads/ci_logo.gif';
+ $dir = preg_replace('/^(.*\/tests\/).*$/', '$1', __FILE__);
+ $this->upload->file_temp = $dir.'mocks/uploads/ci_logo.gif';
$this->upload->file_ext = '.gif';
$this->upload->file_type = 'image/gif';
$this->assertTrue($this->upload->is_allowed_filetype());
@@ -179,8 +181,9 @@ function test_is_allowed_dimensions()
$this->upload->file_type = 'text/plain';
$this->assertTrue($this->upload->is_allowed_dimensions());
+ $dir = preg_replace('/^(.*\/tests\/).*$/', '$1', __FILE__);
$this->upload->file_type = 'image/gif';
- $this->upload->file_temp = 'mocks/uploads/ci_logo.gif';
+ $this->upload->file_temp = $dir.'mocks/uploads/ci_logo.gif';
$this->upload->max_width = 10;
$this->assertFalse($this->upload->is_allowed_dimensions());
@@ -236,7 +239,8 @@ function test_do_xss_clean()
$this->upload->file_temp = vfsStream::url('file3.txt');
$this->assertFalse($this->upload->do_xss_clean());
- $this->upload->file_temp = 'mocks/uploads/ci_logo.gif';
+ $dir = preg_replace('/^(.*\/tests\/).*$/', '$1', __FILE__);
+ $this->upload->file_temp = $dir.'mocks/uploads/ci_logo.gif';
$this->assertTrue($this->upload->do_xss_clean());
}

0 comments on commit 1cebce9

Please sign in to comment.