LiveDocxTest.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Service_LiveDocx
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: $
  21. */
  22. if (!defined('PHPUnit_MAIN_METHOD')) {
  23. define('PHPUnit_MAIN_METHOD', 'Zend_Service_LiveDocx_LiveDocxTest::main');
  24. }
  25. require_once 'Zend/Service/LiveDocx/MailMerge.php';
  26. /**
  27. * Zend_Service_LiveDocx test case
  28. *
  29. * @category Zend
  30. * @package Zend_Service_LiveDocx
  31. * @subpackage UnitTests
  32. * @group Zend_Service
  33. * @group Zend_Service_LiveDocx
  34. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  35. * @license http://framework.zend.com/license/new-bsd New BSD License
  36. * @version $Id: $
  37. */
  38. class Zend_Service_LiveDocX_LiveDocxTest extends PHPUnit_Framework_TestCase
  39. {
  40. public $phpLiveDocx;
  41. public static function main()
  42. {
  43. $suite = new PHPUnit_Framework_TestSuite(__CLASS__);
  44. $result = PHPUnit_TextUI_TestRunner::run($suite);
  45. }
  46. public function setUp()
  47. {
  48. if (!constant('TESTS_ZEND_SERVICE_LIVEDOCX_USERNAME')
  49. || !constant('TESTS_ZEND_SERVICE_LIVEDOCX_PASSWORD')
  50. ) {
  51. $this->markTestSkipped('LiveDocx tests disabled');
  52. return;
  53. }
  54. $this->phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
  55. $this->phpLiveDocx->setUsername(TESTS_ZEND_SERVICE_LIVEDOCX_USERNAME)
  56. ->setPassword(TESTS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
  57. foreach ($this->phpLiveDocx->listTemplates() as $template) {
  58. $this->phpLiveDocx->deleteTemplate($template['filename']);
  59. }
  60. }
  61. public function tearDown ()
  62. {
  63. if (isset($this->phpLiveDocx)) {
  64. foreach ($this->phpLiveDocx->listTemplates() as $template) {
  65. $this->phpLiveDocx->deleteTemplate($template['filename']);
  66. }
  67. unset($this->phpLiveDocx);
  68. }
  69. }
  70. public function testGetFormat ()
  71. {
  72. $this->assertEquals('', $this->phpLiveDocx->getFormat('document'));
  73. $this->assertEquals('doc', $this->phpLiveDocx->getFormat('document.doc'));
  74. $this->assertEquals('doc', $this->phpLiveDocx->getFormat('document-123.doc'));
  75. $this->assertEquals('doc', $this->phpLiveDocx->getFormat('document123.doc'));
  76. $this->assertEquals('doc', $this->phpLiveDocx->getFormat('document.123.doc'));
  77. }
  78. public function testGetVersion ()
  79. {
  80. $expectedResults = '2.0';
  81. $this->assertEquals($expectedResults, $this->phpLiveDocx->getVersion());
  82. }
  83. }
  84. if (PHPUnit_MAIN_METHOD == 'Zend_Service_LiveDocx_LiveDocxTest::main') {
  85. Zend_Service_LiveDocx_LiveDocxTest::main();
  86. }