SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/tests/fileTest.php

  1. <?php
  2. /*
  3.  * Copyright (C) 2017 Karmabunny Pty Ltd.
  4.  *
  5.  * This file is a part of SproutCMS.
  6.  *
  7.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  8.  * of the GNU General Public License as published by the Free Software Foundation, either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * For more information, visit <http://getsproutcms.com>.
  12.  */
  13.  
  14. use Sprout\Helpers\File;
  15.  
  16.  
  17. class fileTest extends PHPUnit_Framework_TestCase
  18. {
  19.  
  20. public function testMimetype()
  21. {
  22. $this->assertEquals('image/jpeg', File::mimetype('test.jpg'));
  23. $this->assertEquals('image/jpeg', File::mimetype('test.jpeg'));
  24. $this->assertEquals('application/octet-stream', File::mimetype('test.poo'));
  25. }
  26.  
  27. public function testGetResizeFilename()
  28. {
  29. $this->assertEquals('test.small.jpg', File::getResizeFilename('test.jpg', 'small'));
  30. $this->assertEquals('test.large.jpg', File::getResizeFilename('test.jpg', 'large'));
  31. $this->assertEquals('test.large.png', File::getResizeFilename('test.jpg', 'large', 'png'));
  32. }
  33.  
  34. public function testParseSizeStringSimple()
  35. {
  36. $this->assertEquals(array('c', 100, 100, 'center', 'center', null), File::parseSizeString('c100x100'));
  37. $this->assertEquals(array('c', 100, 150, 'center', 'center', null), File::parseSizeString('c100x150'));
  38. }
  39.  
  40. public function testParseSizeStringPosition()
  41. {
  42. $this->assertEquals(array('c', 100, 100, 'left', 'top', null), File::parseSizeString('c100x100-lt'));
  43. $this->assertEquals(array('c', 100, 150, 'left', 'top', null), File::parseSizeString('c100x150-lt'));
  44. $this->assertEquals(array('c', 100, 150, 'right', 'top', null), File::parseSizeString('c100x150-rt'));
  45. }
  46.  
  47. public function testParseSizeStringQuality()
  48. {
  49. $this->assertEquals(array('c', 100, 150, 'left', 'top', 10), File::parseSizeString('c100x150-lt~10'));
  50. $this->assertEquals(array('c', 100, 150, 'right', 'top', 100), File::parseSizeString('c100x150-rt~100'));
  51. $this->assertEquals(array('c', 100, 150, 'center', 'center', 10), File::parseSizeString('c100x150~10'));
  52. $this->assertEquals(array('c', 100, 150, 'center', 'center', 100), File::parseSizeString('c100x150~100'));
  53. }
  54. }
  55.