diff --git a/tests/unit/eHelperTest.php b/tests/unit/eHelperTest.php new file mode 100644 index 000000000..33fe024e7 --- /dev/null +++ b/tests/unit/eHelperTest.php @@ -0,0 +1,119 @@ +hp = $this->make('eHelper'); + } + catch (Exception $e) + { + $this->fail("Couldn't load eHelper object"); + } + + } + +/* + + public function testFormatMetaTitle() + { + + } + + public function testFormatMetaKeys() + { + + } + + public function testGetMemoryUsage() + { + + } + + public function testUnderscore() + { + + } + + public function testFormatMetaDescription() + { + + } + + public function testSecureIdAttr() + { + + } + + public function testTitle2sef() + { + + } + + public function testCamelize() + { + + } + + public function testScParams() + { + + } + + public function testLabelize() + { + + } + + public function testSecureClassAttr() + { + + } + + public function testSecureStyleAttr() + { + + } + + public function testScDualParams() + { + + } + + public function testDasherize() + { + + } + + public function testParseMemorySize() + { + + } + + public function testBuildAttr() + { + + } + + public function testSecureSef() + { + + }*/ + + + + } diff --git a/tests/unit/e_fileTest.php b/tests/unit/e_fileTest.php index 5ec380017..cf5fb4804 100644 --- a/tests/unit/e_fileTest.php +++ b/tests/unit/e_fileTest.php @@ -14,6 +14,7 @@ /** @var e_file */ protected $fl; + protected $exploitFile = ''; protected function _before() { @@ -26,9 +27,72 @@ $this->fail("Couldn't load e_file object"); } + $this->exploitFile = e_TEMP."test_exploit_file.jpg"; + + $content = ""; + + file_put_contents($this->exploitFile,$content); + + } + + protected function _after() + { + unlink($this->exploitFile); } + public function testIsClean() + { + + $isCleanTest = array( + array('path'=>$this->exploitFile, 'expected' => false), // suspicious + array('path'=>e_SYSTEM."filetypes.xml", 'expected' => true), // okay + array('path'=>e_PLUGIN."gallery/images/butterfly.jpg", 'expected' => true), // okay + ); + + foreach($isCleanTest as $file) + { + $actual = $this->fl->isClean($file['path'], $file['path']); + $this->assertEquals($file['expected'],$actual, "isClean() failed with error code: ".$this->fl->getErrorCode()); + } + + } + + public function testGetAllowedFileTypes() + { + $actual = $this->fl->getAllowedFileTypes(); + + $expected = array ( + 'zip' => 2048, + 'gz' => 2048, + 'jpg' => 2048, + 'jpeg' => 2048, + 'png' => 2048, + 'gif' => 2048, + 'xml' => 2048, + 'pdf' => 2048, + ); + + $this->assertEquals($expected,$actual); + + } + + public function testIsAllowedType() + { + + $isAllowedTest = array( + array('path'=> 'somefile.bla', 'expected' => false), // suspicious + array('path'=> e_SYSTEM."filetypes.xml", 'expected' => true), // okay + array('path'=> e_PLUGIN."gallery/images/butterfly.jpg", 'expected' => true), // okay + ); + + foreach($isAllowedTest as $file) + { + $actual = $this->fl->isAllowedType($file['path']); + // $this->assertEquals($file['expected'],$actual, "isAllowedType() failed on: ".$file['path']); + } + + } /* public function testSend() {