test_pens_package_handler.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * This file is part of php-pens.
  4. *
  5. * php-pens is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * php-pens is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with php-pens. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * Unit tests for the PENSPackageHandler class
  20. *
  21. * This class provides unit tests for the PENSPackageHandler class
  22. *
  23. * @package PENS
  24. * @subpackage Tests
  25. * @author Guillaume Viguier-Just <guillaume@viguierjust.com>
  26. * @licence http://www.gnu.org/licenses/gpl.txt
  27. */
  28. require_once 'simpletest/autorun.php';
  29. require_once __DIR__.'/../pens.php';
  30. class MyPackageHandler extends PENSPackageHandler {
  31. public function processPackage($request, $path_to_package) {
  32. }
  33. }
  34. /**
  35. * Unit tests for the PENSPackageHandler class
  36. *
  37. * This class provides unit tests for the PENSPackageHandler class
  38. *
  39. * @package PENS
  40. * @subpackage Tests
  41. * @author Guillaume Viguier-Just <guillaume@viguierjust.com>
  42. * @licence http://www.gnu.org/licenses/gpl.txt
  43. */
  44. class TestPENSPackageHandler extends UnitTestCase {
  45. public function testSupportedPackageTypesInvalid() {
  46. $object = new MyPackageHandler();
  47. $object->setSupportedPackageTypes("testing");
  48. $this->assertEqual($object->getSupportedPackageTypes(), null);
  49. }
  50. public function testSupportedPackageTypesInvalid2() {
  51. $object = new MyPackageHandler();
  52. $object->setSupportedPackageTypes(array("aicc-pkg", "testing"));
  53. $this->assertEqual($object->getSupportedPackageTypes(), array("aicc-pkg"));
  54. }
  55. public function testSupportedPackageTypesValid() {
  56. $object = new MyPackageHandler();
  57. $object->setSupportedPackageTypes(array("aicc-pkg", "lms-qti"));
  58. $this->assertEqual($object->getSupportedPackageTypes(), array("aicc-pkg", "lms-qti"));
  59. }
  60. public function testSupportedPackageFormatsInvalid() {
  61. $object = new MyPackageHandler();
  62. $object->setSupportedPackageFormats("testing");
  63. $this->assertEqual($object->getSupportedPackageFormats(), null);
  64. }
  65. public function testSupportedPackageFormatsInvalid2() {
  66. $object = new MyPackageHandler();
  67. $object->setSupportedPackageFormats(array("zip", "testing"));
  68. $this->assertEqual($object->getSupportedPackageFormats(), array("zip"));
  69. }
  70. public function testSupportedPackageFormatsValid() {
  71. $object = new MyPackageHandler();
  72. $object->setSupportedPackageFormats(array("zip", "jar"));
  73. $this->assertEqual($object->getSupportedPackageFormats(), array("zip", "jar"));
  74. }
  75. }