This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/includes/kohana/system/tests/kohana/FileTest.php

78 lines
1.8 KiB
PHP
Raw Normal View History

2010-08-21 04:43:03 +00:00
<?php defined('SYSPATH') OR die('Kohana bootstrap needs to be included before tests run');
/**
* Tests Kohana File helper
*
* @group kohana
* @group kohana.url
*
2011-05-13 06:00:25 +00:00
* @package Kohana
* @category Tests
2010-08-21 04:43:03 +00:00
* @author Kohana Team
* @author Jeremy Bush <contractfrombelow@gmail.com>
2011-05-13 06:00:25 +00:00
* @copyright (c) 2008-2011 Kohana Team
* @license http://kohanaframework.org/license
2010-08-21 04:43:03 +00:00
*/
2011-05-13 06:00:25 +00:00
class Kohana_FileTest extends Unittest_TestCase
2010-08-21 04:43:03 +00:00
{
/**
* Provides test data for test_sanitize()
2011-05-13 06:00:25 +00:00
*
2010-08-21 04:43:03 +00:00
* @return array
*/
public function provider_mime()
{
return array(
// $value, $result
array(Kohana::find_file('classes', 'file')),
array(Kohana::find_file('tests', 'test_data/github', 'png')),
);
}
/**
* Tests File::mime()
*
* @test
* @dataProvider provider_mime
* @param boolean $input Input for File::mime
* @param boolean $expected Output for File::mime
*/
public function test_mime($input)
{
$this->assertSame(1, preg_match('/^(?:application|audio|image|message|multipart|text|video)\/[a-z.+0-9-]+$/i', File::mime($input)));
}
/**
* Provides test data for test_split_join()
2011-05-13 06:00:25 +00:00
*
2010-08-21 04:43:03 +00:00
* @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));
2011-05-13 06:00:25 +00:00
foreach (glob(Kohana::find_file('tests', 'test_data/github', 'png').'.*') as $file)
{
unlink($file);
}
2010-08-21 04:43:03 +00:00
}
}