ChmodLibTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. $this->Chmod = new ChmodLib();
  11. }
  12. /** Start **/
  13. public function testConvertFromOctal() {
  14. $is = $this->Chmod->convertFromOctal(0777);
  15. $expected = '777';
  16. $this->assertEquals($expected, $is);
  17. $is = $this->Chmod->convertFromOctal(0777, true);
  18. $expected = '0777';
  19. $this->assertEquals($expected, $is);
  20. }
  21. public function testConvertToOctal() {
  22. $is = $this->Chmod->convertToOctal(777);
  23. $expected = 0777;
  24. $this->assertEquals($expected, $is);
  25. $is = $this->Chmod->convertToOctal('777');
  26. $expected = 0777;
  27. $this->assertEquals($expected, $is);
  28. $is = $this->Chmod->convertToOctal('0777');
  29. $expected = 0777;
  30. $this->assertEquals($expected, $is);
  31. }
  32. public function testChmod() {
  33. $this->Chmod->setUser(true, true, true);
  34. $this->Chmod->setGroup(true, true, true);
  35. $this->Chmod->setOther(true, true, true);
  36. $is = $this->Chmod->getMode();
  37. $expected = 0777;
  38. $this->assertEquals($expected, $is);
  39. $is = $this->Chmod->getMode(array('type'=>'string'));
  40. $expected = '777';
  41. $this->assertEquals($expected, $is);
  42. $is = $this->Chmod->getMode(array('type'=>'int'));
  43. $expected = 777;
  44. $this->assertEquals($expected, $is);
  45. $is = $this->Chmod->getMode(array('type'=>'symbolic'));
  46. $expected = 'rwxrwxrwx';
  47. $this->assertEquals($expected, $is);
  48. }
  49. /** End **/
  50. }