FactoryTest.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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_Cloud
  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. */
  21. // Call Zend_Cloud_Infrastructure_FactoryTest::main() if this source file is executed directly.
  22. if (!defined("PHPUnit_MAIN_METHOD")) {
  23. define("PHPUnit_MAIN_METHOD", "Zend_Cloud_Infrastructure_FactoryTest::main");
  24. }
  25. /**
  26. * @see Zend_Config_Ini
  27. */
  28. require_once 'Zend/Config/Ini.php';
  29. /**
  30. * @see Zend_Cloud_Infrastructure_Factory
  31. */
  32. require_once 'Zend/Cloud/Infrastructure/Factory.php';
  33. /**
  34. * @see Zend_Cloud_Infrastructure_Adapter_Ec2
  35. */
  36. require_once 'Zend/Cloud/Infrastructure/Adapter/Ec2.php';
  37. /**
  38. * Test class for Zend_Cloud_Infrastructure_Factory
  39. *
  40. * @category Zend
  41. * @package Zend_Cloud
  42. * @subpackage UnitTests
  43. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  44. * @license http://framework.zend.com/license/new-bsd New BSD License
  45. * @group Zend_Cloud
  46. */
  47. class Zend_Cloud_Infrastructure_FactoryTest extends PHPUnit_Framework_TestCase
  48. {
  49. /**
  50. * Runs the test methods of this class.
  51. *
  52. * @return void
  53. */
  54. public static function main()
  55. {
  56. $suite = new PHPUnit_Framework_TestSuite(__CLASS__);
  57. $result = PHPUnit_TextUI_TestRunner::run($suite);
  58. }
  59. public function testGetInfrastructureAdapterKey()
  60. {
  61. $this->assertTrue(is_string(Zend_Cloud_Infrastructure_Factory::INFRASTRUCTURE_ADAPTER_KEY));
  62. }
  63. public function testGetAdapterWithConfig() {
  64. // EC2 adapter
  65. $Ec2Adapter = Zend_Cloud_Infrastructure_Factory::getAdapter(
  66. new Zend_Config(Zend_Cloud_Infrastructure_Adapter_Ec2Test::getConfigArray())
  67. );
  68. $this->assertEquals('Zend_Cloud_Infrastructure_Adapter_Ec2', get_class($Ec2Adapter));
  69. // Rackspace adapter
  70. $rackspaceAdapter = Zend_Cloud_Infrastructure_Factory::getAdapter(
  71. new Zend_Config(Zend_Cloud_Infrastructure_Adapter_RackspaceTest::getConfigArray())
  72. );
  73. $this->assertEquals('Zend_Cloud_Infrastructure_Adapter_Rackspace', get_class($rackspaceAdapter));
  74. }
  75. }
  76. // Call Zend_Cloud_Infrastructure_FactoryTest::main() if this source file is executed directly.
  77. if (PHPUnit_MAIN_METHOD == "Zend_Cloud_Infrastructure_FactoryTest::main") {
  78. Zend_Cloud_Infrastructure_FactoryTest::main();
  79. }