ChmodLibTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. App::uses('ChmodLib', 'Tools.Utility');
  3. /**
  4. * testing
  5. */
  6. class ChmodLibTest extends CakeTestCase {
  7. public $Chmod = null;
  8. public function setUp() {
  9. parent::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. }