2013-04-22 04:09:50 +00:00
< ? php defined ( 'SYSPATH' ) OR die ( 'Kohana bootstrap needs to be included before tests run' );
/**
* Tests Kohana File helper
*
* @ group kohana
* @ group kohana . core
2016-05-01 10:50:24 +00:00
* @ group kohana . core . file
2013-04-22 04:09:50 +00:00
*
* @ package Kohana
* @ category Tests
* @ author Kohana Team
* @ author Jeremy Bush < contractfrombelow @ gmail . com >
* @ copyright ( c ) 2008 - 2012 Kohana Team
* @ license http :// kohanaframework . org / license
*/
class Kohana_FileTest extends Unittest_TestCase
{
/**
* Provides test data for test_sanitize ()
*
* @ return array
*/
public function provider_mime ()
{
return array (
// $value, $result
2016-05-01 10:50:24 +00:00
array ( Kohana :: find_file ( 'tests' , 'test_data/github' , 'png' ), 'image/png' ),
2013-04-22 04:09:50 +00:00
);
}
/**
* Tests File :: mime ()
*
* @ test
* @ dataProvider provider_mime
* @ param boolean $input Input for File :: mime
* @ param boolean $expected Output for File :: mime
*/
2016-05-01 10:50:24 +00:00
public function test_mime ( $input , $expected )
2013-04-22 04:09:50 +00:00
{
2016-05-01 10:50:24 +00:00
//@todo: File::mime coverage needs significant improvement or to be dropped for a composer package - it's a "horribly unreliable" method with very little testing
$this -> assertSame ( $expected , File :: mime ( $input ));
2013-04-22 04:09:50 +00:00
}
/**
* Provides test data for test_split_join ()
*
* @ return array
*/
public function provider_split_join ()
{
return array (
// $value, $result
array ( Kohana :: find_file ( 'tests' , 'test_data/github' , 'png' ), . 01 , 1 ),
);
}
/**
* Tests File :: mime ()
*
* @ test
* @ dataProvider provider_split_join
* @ param boolean $input Input for File :: split
* @ param boolean $peices Input for File :: split
* @ param boolean $expected Output for File :: splut
*/
public function test_split_join ( $input , $peices , $expected )
{
$this -> assertSame ( $expected , File :: split ( $input , $peices ));
$this -> assertSame ( $expected , File :: join ( $input ));
foreach ( glob ( Kohana :: find_file ( 'tests' , 'test_data/github' , 'png' ) . '.*' ) as $file )
{
unlink ( $file );
}
}
}