features_windows_test.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <?php
  2. /**
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one
  5. * or more contributor license agreements. See the NOTICE file
  6. * distributed with this work for additional information
  7. * regarding copyright ownership. The ASF licenses this file
  8. * to you under the Apache License, Version 2.0 (the
  9. * "License"); you may not use this file except in compliance
  10. * with the License. You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing,
  15. * software distributed under the License is distributed on an
  16. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17. * KIND, either express or implied. See the License for the
  18. * specific language governing permissions and limitations
  19. * under the License.
  20. *
  21. * @package Base
  22. * @subpackage Tests
  23. * @version //autogentag//
  24. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
  25. */
  26. /**
  27. * @package Base
  28. * @subpackage Tests
  29. */
  30. class ezcBaseFeaturesWindowsTest extends ezcTestCase
  31. {
  32. protected function setUp()
  33. {
  34. $uname = php_uname( 's' );
  35. if ( substr( $uname, 0, 7 ) != 'Windows' )
  36. {
  37. $this->markTestSkipped( 'Windows tests' );
  38. }
  39. }
  40. public function testSupportsLink()
  41. {
  42. $this->assertFalse( ezcBaseFeatures::supportsLink() );
  43. }
  44. public function testSupportsSymLink()
  45. {
  46. $this->assertFalse( ezcBaseFeatures::supportsSymLink() );
  47. }
  48. public function testSupportsUserId()
  49. {
  50. $this->assertFalse( ezcBaseFeatures::supportsUserId() );
  51. }
  52. /* // Need to find a way to make this test work, as setting global enviroment variables
  53. // is not working (putenv( "PATH=" ) doesn't unset $_ENV["PATH"])
  54. // One solution would be to use in the ezcBaseFeatures::getPath():
  55. // getenv( 'PATH' ) instead of $_ENV['PATH'] (but that won't work under IIS).
  56. public function testHasImageIdentifyNoPath()
  57. {
  58. $envPath = getenv( 'PATH' );
  59. putenv( "PATH=" );
  60. $this->assertEquals( false, ezcBaseFeatures::hasImageIdentify() );
  61. putenv( "PATH={$envPath}" );
  62. }
  63. */
  64. public function testHasImageConvert()
  65. {
  66. $this->assertTrue( ezcBaseFeatures::hasImageConvert() );
  67. }
  68. public function testGetImageConvertExecutable()
  69. {
  70. $this->assertNotNull( ezcBaseFeatures::getImageConvertExecutable() );
  71. }
  72. public function testGetImageIdentifyExecutable()
  73. {
  74. $this->assertNotNull( ezcBaseFeatures::getImageIdentifyExecutable() );
  75. }
  76. public function testHasImageIdentify()
  77. {
  78. $this->assertTrue( ezcBaseFeatures::hasImageIdentify() );
  79. }
  80. public function testHasExtensionSupport1()
  81. {
  82. $this->assertTrue( ezcBaseFeatures::hasExtensionSupport( 'standard' ) );
  83. }
  84. public function testHasExtensionSupportNotFound1()
  85. {
  86. $this->assertEquals( false, ezcBaseFeatures::hasExtensionSupport( 'non_existent_extension' ) );
  87. try
  88. {
  89. throw new ezcBaseExtensionNotFoundException( 'non_existent_extension', null, 'This is just a test.' );
  90. }
  91. catch ( ezcBaseExtensionNotFoundException $e )
  92. {
  93. $this->assertEquals( "The extension 'non_existent_extension' could not be found. This is just a test.",
  94. $e->getMessage() );
  95. }
  96. }
  97. public function testHasExtensionSupportNotFound2()
  98. {
  99. $this->assertEquals( false, ezcBaseFeatures::hasExtensionSupport( 'non_existent_extension' ) );
  100. try
  101. {
  102. throw new ezcBaseExtensionNotFoundException( 'non_existent_extension', '1.2', 'This is just a test.' );
  103. }
  104. catch ( ezcBaseExtensionNotFoundException $e )
  105. {
  106. $this->assertEquals( "The extension 'non_existent_extension' with version '1.2' could not be found. This is just a test.",
  107. $e->getMessage() );
  108. }
  109. }
  110. public function testHasFunction1()
  111. {
  112. $this->assertEquals( true, ezcBaseFeatures::hasFunction( 'function_exists' ) );
  113. }
  114. public function testHasFunction2()
  115. {
  116. $this->assertEquals( false, ezcBaseFeatures::hasFunction( 'non_existent_function_in_php' ) );
  117. }
  118. public function testHasExtensionSupport2()
  119. {
  120. $this->assertEquals( true, ezcBaseFeatures::hasExtensionSupport( 'date', '5.1.0' ) );
  121. }
  122. public function testClassExists()
  123. {
  124. $this->assertEquals( true, ezcBaseFeatures::classExists( 'Exception', false ) );
  125. }
  126. public function testClassExistsAutoload()
  127. {
  128. $this->assertEquals( true, ezcBaseFeatures::classExists( 'ezcBaseFeatures' ) );
  129. }
  130. public function testClassExistsNotFound()
  131. {
  132. $this->assertEquals( false, ezcBaseFeatures::classExists( 'ezcBaseNonExistingClass', false ) );
  133. }
  134. public function testClassExistsNotFoundAutoload()
  135. {
  136. $this->assertEquals( false, ezcBaseFeatures::classExists( 'ezcBaseNonExistingClass' ) );
  137. }
  138. public static function suite()
  139. {
  140. return new PHPUnit_Framework_TestSuite( __CLASS__ );
  141. }
  142. }
  143. ?>