stringutils.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * Copyright (c) 2014 Lukas Reschke <lukas@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. use \OC\Security\StringUtils;
  9. class StringUtilsTest extends \Test\TestCase {
  10. public function dataProvider()
  11. {
  12. return array(
  13. array('Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt.', 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt.'),
  14. array('', ''),
  15. array('我看这本书。 我看這本書', '我看这本书。 我看這本書'),
  16. array('GpKY9fSnWNJbES99zVGvA', 'GpKY9fSnWNJbES99zVGvA')
  17. );
  18. }
  19. /**
  20. * @dataProvider dataProvider
  21. */
  22. function testWrongEquals($string) {
  23. $this->assertFalse(StringUtils::equals($string, 'A Completely Wrong String'));
  24. $this->assertFalse(StringUtils::equals($string, null));
  25. }
  26. /**
  27. * @dataProvider dataProvider
  28. */
  29. function testTrueEquals($string, $expected) {
  30. $this->assertTrue(StringUtils::equals($string, $expected));
  31. }
  32. }