LiveDocxTest.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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-2009 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. /**
  26. * Test helper
  27. */
  28. require_once dirname(__FILE__) . '/../../../TestHelper.php';
  29. /** Zend_Service_LiveDocx_MailMerge */
  30. require_once 'Zend/Service/LiveDocx/MailMerge.php';
  31. /**
  32. * Zend_Service_LiveDocx test case
  33. *
  34. * @category Zend
  35. * @package Zend_Service_LiveDocx
  36. * @subpackage UnitTests
  37. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  38. * @license http://framework.zend.com/license/new-bsd New BSD License
  39. * @version $Id: $
  40. */
  41. class Zend_Service_LiveDocX_LiveDocxTest extends PHPUnit_Framework_TestCase
  42. {
  43. public $phpLiveDocx;
  44. public static function main()
  45. {
  46. $suite = new PHPUnit_Framework_TestSuite(__CLASS__);
  47. $result = PHPUnit_TextUI_TestRunner::run($suite);
  48. }
  49. public function setUp()
  50. {
  51. if (!constant('TESTS_ZEND_SERVICE_LIVEDOCX_USERNAME')
  52. || !constant('TESTS_ZEND_SERVICE_LIVEDOCX_PASSWORD')
  53. ) {
  54. $this->markTestSkipped('LiveDocx tests disabled');
  55. return;
  56. }
  57. $this->phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
  58. $this->phpLiveDocx->setUsername(TESTS_ZEND_SERVICE_LIVEDOCX_USERNAME)
  59. ->setPassword(TESTS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
  60. foreach ($this->phpLiveDocx->listTemplates() as $template) {
  61. $this->phpLiveDocx->deleteTemplate($template['filename']);
  62. }
  63. }
  64. public function tearDown ()
  65. {
  66. foreach ($this->phpLiveDocx->listTemplates() as $template) {
  67. $this->phpLiveDocx->deleteTemplate($template['filename']);
  68. }
  69. unset($this->phpLiveDocx);
  70. }
  71. public function testGetFormat ()
  72. {
  73. $this->assertEquals('', $this->phpLiveDocx->getFormat('document'));
  74. $this->assertEquals('doc', $this->phpLiveDocx->getFormat('document.doc'));
  75. $this->assertEquals('doc', $this->phpLiveDocx->getFormat('document-123.doc'));
  76. $this->assertEquals('doc', $this->phpLiveDocx->getFormat('document123.doc'));
  77. $this->assertEquals('doc', $this->phpLiveDocx->getFormat('document.123.doc'));
  78. }
  79. public function testGetVersion ()
  80. {
  81. $expectedResults = '1.2';
  82. $this->assertEquals($expectedResults, $this->phpLiveDocx->getVersion());
  83. }
  84. }
  85. if (PHPUnit_MAIN_METHOD == 'Zend_Service_LiveDocx_LiveDocxTest::main') {
  86. Zend_Service_LiveDocx_LiveDocxTest::main();
  87. }