FileTest.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php defined('SYSPATH') OR die('Kohana bootstrap needs to be included before tests run');
  2. /**
  3. * Tests Kohana File helper
  4. *
  5. * @group kohana
  6. * @group kohana.core
  7. * @group kohana.core.url
  8. *
  9. * @package Kohana
  10. * @category Tests
  11. * @author Kohana Team
  12. * @author Jeremy Bush <[email protected]>
  13. * @copyright (c) 2008-2012 Kohana Team
  14. * @license http://kohanaframework.org/license
  15. */
  16. class Kohana_FileTest extends Unittest_TestCase
  17. {
  18. /**
  19. * Provides test data for test_sanitize()
  20. *
  21. * @return array
  22. */
  23. public function provider_mime()
  24. {
  25. return array(
  26. // $value, $result
  27. array(Kohana::find_file('classes', 'File')),
  28. array(Kohana::find_file('tests', 'test_data/github', 'png')),
  29. );
  30. }
  31. /**
  32. * Tests File::mime()
  33. *
  34. * @test
  35. * @dataProvider provider_mime
  36. * @param boolean $input Input for File::mime
  37. * @param boolean $expected Output for File::mime
  38. */
  39. public function test_mime($input)
  40. {
  41. $this->markTestSkipped(
  42. 'This test doesn\'t do anything useful!'
  43. );
  44. $this->assertSame(1, preg_match('/^(?:application|audio|image|message|multipart|text|video)\/[a-z.+0-9-]+$/i', File::mime($input)));
  45. }
  46. /**
  47. * Provides test data for test_split_join()
  48. *
  49. * @return array
  50. */
  51. public function provider_split_join()
  52. {
  53. return array(
  54. // $value, $result
  55. array(Kohana::find_file('tests', 'test_data/github', 'png'), .01, 1),
  56. );
  57. }
  58. /**
  59. * Tests File::mime()
  60. *
  61. * @test
  62. * @dataProvider provider_split_join
  63. * @param boolean $input Input for File::split
  64. * @param boolean $peices Input for File::split
  65. * @param boolean $expected Output for File::splut
  66. */
  67. public function test_split_join($input, $peices, $expected)
  68. {
  69. $this->assertSame($expected, File::split($input, $peices));
  70. $this->assertSame($expected, File::join($input));
  71. foreach (glob(Kohana::find_file('tests', 'test_data/github', 'png').'.*') as $file)
  72. {
  73. unlink($file);
  74. }
  75. }
  76. }