ErrorHandlerTest.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Bjoern Schiessle
  6. * @copyright 2014 Bjoern Schiessle <schiessle@owncloud.com>
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. namespace Test;
  23. class ErrorHandlerTest extends \Test\TestCase {
  24. /**
  25. * provide username, password combinations for testRemovePassword
  26. * @return array
  27. */
  28. function passwordProvider() {
  29. return array(
  30. array('user', 'password'),
  31. array('user@owncloud.org', 'password'),
  32. array('user', 'pass@word'),
  33. array('us:er', 'password'),
  34. array('user', 'pass:word'),
  35. );
  36. }
  37. /**
  38. * @dataProvider passwordProvider
  39. * @param string $username
  40. * @param string $password
  41. */
  42. function testRemovePassword($username, $password) {
  43. $url = 'http://'.$username.':'.$password.'@owncloud.org';
  44. $expectedResult = 'http://xxx:xxx@owncloud.org';
  45. $result = TestableErrorHandler::testRemovePassword($url);
  46. $this->assertEquals($expectedResult, $result);
  47. }
  48. }
  49. /**
  50. * dummy class to access protected methods of \OC\Log\ErrorHandler
  51. */
  52. class TestableErrorHandler extends \OC\Log\ErrorHandler {
  53. /**
  54. * @param string $msg
  55. */
  56. public static function testRemovePassword($msg) {
  57. return self::removePassword($msg);
  58. }
  59. }