ChmodLibTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. App::uses('ChmodLib', 'Tools.Utility');
  3. /**
  4. * testing
  5. * 2009-07-15 ms
  6. */
  7. class ChmodLibTest extends CakeTestCase {
  8. public $Chmod = null;
  9. public function setUp() {
  10. parent::setUp();
  11. $this->Chmod = new ChmodLib();
  12. }
  13. /** Start **/
  14. public function testConvertFromOctal() {
  15. $is = $this->Chmod->convertFromOctal(0777);
  16. $expected = '777';
  17. $this->assertEquals($expected, $is);
  18. $is = $this->Chmod->convertFromOctal(0777, true);
  19. $expected = '0777';
  20. $this->assertEquals($expected, $is);
  21. }
  22. public function testConvertToOctal() {
  23. $is = $this->Chmod->convertToOctal(777);
  24. $expected = 0777;
  25. $this->assertEquals($expected, $is);
  26. $is = $this->Chmod->convertToOctal('777');
  27. $expected = 0777;
  28. $this->assertEquals($expected, $is);
  29. $is = $this->Chmod->convertToOctal('0777');
  30. $expected = 0777;
  31. $this->assertEquals($expected, $is);
  32. }
  33. public function testChmod() {
  34. $this->Chmod->setUser(true, true, true);
  35. $this->Chmod->setGroup(true, true, true);
  36. $this->Chmod->setOther(true, true, true);
  37. $is = $this->Chmod->getMode();
  38. $expected = 0777;
  39. $this->assertEquals($expected, $is);
  40. $is = $this->Chmod->getMode(array('type'=>'string'));
  41. $expected = '777';
  42. $this->assertEquals($expected, $is);
  43. $is = $this->Chmod->getMode(array('type'=>'int'));
  44. $expected = 777;
  45. $this->assertEquals($expected, $is);
  46. $is = $this->Chmod->getMode(array('type'=>'symbolic'));
  47. $expected = 'rwxrwxrwx';
  48. $this->assertEquals($expected, $is);
  49. }
  50. /** End **/
  51. }