PageRenderTime 69ms CodeModel.GetById 38ms RepoModel.GetById 0ms app.codeStats 1ms

/Webdav/tests/server_configuration_manager_test.php

https://github.com/Yannix/zetacomponents
PHP | 1365 lines | 1197 code | 128 blank | 40 comment | 0 complexity | da7d4d1bdc942b484db6a505da9c0d58 MD5 | raw file
  1. <?php
  2. /**
  3. * Basic test cases for the memory backend.
  4. *
  5. * Licensed to the Apache Software Foundation (ASF) under one
  6. * or more contributor license agreements. See the NOTICE file
  7. * distributed with this work for additional information
  8. * regarding copyright ownership. The ASF licenses this file
  9. * to you under the Apache License, Version 2.0 (the
  10. * "License"); you may not use this file except in compliance
  11. * with the License. You may obtain a copy of the License at
  12. *
  13. * http://www.apache.org/licenses/LICENSE-2.0
  14. *
  15. * Unless required by applicable law or agreed to in writing,
  16. * software distributed under the License is distributed on an
  17. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18. * KIND, either express or implied. See the License for the
  19. * specific language governing permissions and limitations
  20. * under the License.
  21. *
  22. * @package Webdav
  23. * @subpackage Tests
  24. * @version //autogentag//
  25. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
  26. */
  27. /**
  28. * Reqiuire base test
  29. */
  30. /**
  31. * Custom classes to test inheritence.
  32. */
  33. require_once 'classes/foo_custom_classes.php';
  34. /**
  35. * Tests for ezcWebdavServerConfigurationManager class.
  36. *
  37. * @package Webdav
  38. * @subpackage Tests
  39. */
  40. class ezcWebdavServerConfigurationManagerTest extends ezcTestCase
  41. {
  42. public static function suite()
  43. {
  44. return new PHPUnit_Framework_TestSuite( __CLASS__ );
  45. }
  46. public function testCtor()
  47. {
  48. $dp = new ezcWebdavServerConfigurationManager();
  49. $this->assertAttributeEquals(
  50. array(
  51. 0 => new ezcWebdavServerConfiguration(
  52. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  53. 'ezcWebdavMicrosoftCompatibleTransport'
  54. ),
  55. 1 => new ezcWebdavServerConfiguration(
  56. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  57. 'ezcWebdavNautilusCompatibleTransport',
  58. 'ezcWebdavXmlTool',
  59. 'ezcWebdavNautilusPropertyHandler'
  60. ),
  61. 2 => new ezcWebdavServerConfiguration(
  62. '(Konqueror)i',
  63. 'ezcWebdavKonquerorCompatibleTransport'
  64. ),
  65. 3 => new ezcWebdavServerConfiguration(),
  66. ),
  67. 'configurations',
  68. $dp,
  69. 'Default properties not created correctly on empty ctor.'
  70. );
  71. }
  72. public function testInsertBeforeSuccess()
  73. {
  74. $dp = new ezcWebdavServerConfigurationManager();
  75. $firstCfg = new ezcWebdavServerConfiguration();
  76. $secondCfg = new ezcWebdavServerConfiguration(
  77. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  78. 'ezcWebdavMicrosoftCompatibleTransport'
  79. );
  80. $thirdCfg = new ezcWebdavServerConfiguration(
  81. '(Konqueror)i',
  82. 'ezcWebdavKonquerorCompatibleTransport'
  83. );
  84. $fourthCfg = new ezcWebdavServerConfiguration(
  85. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  86. 'ezcWebdavNautilusCompatibleTransport',
  87. 'ezcWebdavXmlTool',
  88. 'ezcWebdavNautilusPropertyHandler'
  89. );
  90. $this->assertAttributeEquals(
  91. array(
  92. 0 => $secondCfg,
  93. 1 => $fourthCfg,
  94. 2 => $thirdCfg,
  95. 3 => $firstCfg,
  96. ),
  97. 'configurations',
  98. $dp,
  99. 'Default properties not created correctly on empty ctor.'
  100. );
  101. $fifthCfg = new ezcWebdavServerConfiguration(
  102. 'fooregex'
  103. );
  104. $dp->insertBefore( $fifthCfg );
  105. $this->assertAttributeEquals(
  106. array(
  107. 0 => $fifthCfg,
  108. 1 => $secondCfg,
  109. 2 => $fourthCfg,
  110. 3 => $thirdCfg,
  111. 4 => $firstCfg,
  112. ),
  113. 'configurations',
  114. $dp,
  115. 'Third transport not added correctly.'
  116. );
  117. $sixthCfg = new ezcWebdavServerConfiguration(
  118. 'barregex'
  119. );
  120. $dp->insertBefore( $sixthCfg, 1 );
  121. $this->assertAttributeEquals(
  122. array(
  123. 0 => $fifthCfg,
  124. 1 => $sixthCfg,
  125. 2 => $secondCfg,
  126. 3 => $fourthCfg,
  127. 4 => $thirdCfg,
  128. 5 => $firstCfg,
  129. ),
  130. 'configurations',
  131. $dp,
  132. 'Fourth transport not added correctly.'
  133. );
  134. $dp->insertBefore( $thirdCfg );
  135. $this->assertAttributeEquals(
  136. array(
  137. 0 => $thirdCfg,
  138. 1 => $fifthCfg,
  139. 2 => $sixthCfg,
  140. 3 => $secondCfg,
  141. 4 => $fourthCfg,
  142. 5 => $thirdCfg,
  143. 6 => $firstCfg,
  144. ),
  145. 'configurations',
  146. $dp,
  147. 'Third transport not added correctly, again.'
  148. );
  149. }
  150. public function testInsertBeforeFailure()
  151. {
  152. $dp = new ezcWebdavServerConfigurationManager();
  153. $firstCfg = new ezcWebdavServerConfiguration();
  154. $this->assertAttributeEquals(
  155. array(
  156. 0 => new ezcWebdavServerConfiguration(
  157. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  158. 'ezcWebdavMicrosoftCompatibleTransport'
  159. ),
  160. 1 => new ezcWebdavServerConfiguration(
  161. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  162. 'ezcWebdavNautilusCompatibleTransport',
  163. 'ezcWebdavXmlTool',
  164. 'ezcWebdavNautilusPropertyHandler'
  165. ),
  166. 2 => new ezcWebdavServerConfiguration(
  167. '(Konqueror)i',
  168. 'ezcWebdavKonquerorCompatibleTransport'
  169. ),
  170. 3 => new ezcWebdavServerConfiguration(),
  171. ),
  172. 'configurations',
  173. $dp,
  174. 'Default properties not created correctly on empty ctor.'
  175. );
  176. $secondCfg = new ezcWebdavServerConfiguration(
  177. 'fooregex'
  178. );
  179. try
  180. {
  181. $dp->insertBefore( $secondCfg, 'foo' );
  182. $this->fail( 'ezcBaseValueException not thrown on string $offset.' );
  183. }
  184. catch ( ezcBaseValueException $e ) {}
  185. $this->assertAttributeEquals(
  186. array(
  187. 0 => new ezcWebdavServerConfiguration(
  188. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  189. 'ezcWebdavMicrosoftCompatibleTransport'
  190. ),
  191. 1 => new ezcWebdavServerConfiguration(
  192. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  193. 'ezcWebdavNautilusCompatibleTransport',
  194. 'ezcWebdavXmlTool',
  195. 'ezcWebdavNautilusPropertyHandler'
  196. ),
  197. 2 => new ezcWebdavServerConfiguration(
  198. '(Konqueror)i',
  199. 'ezcWebdavKonquerorCompatibleTransport'
  200. ),
  201. 3 => new ezcWebdavServerConfiguration(),
  202. ),
  203. 'configurations',
  204. $dp,
  205. 'Default properties not created correctly on empty ctor.'
  206. );
  207. try
  208. {
  209. $dp->insertBefore( $secondCfg, -23 );
  210. $this->fail( 'ezcBaseValueException not thrown on negative int $offset.' );
  211. }
  212. catch ( ezcBaseValueException $e ) {}
  213. $this->assertAttributeEquals(
  214. array(
  215. 0 => new ezcWebdavServerConfiguration(
  216. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  217. 'ezcWebdavMicrosoftCompatibleTransport'
  218. ),
  219. 1 => new ezcWebdavServerConfiguration(
  220. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  221. 'ezcWebdavNautilusCompatibleTransport',
  222. 'ezcWebdavXmlTool',
  223. 'ezcWebdavNautilusPropertyHandler'
  224. ),
  225. 2 => new ezcWebdavServerConfiguration(
  226. '(Konqueror)i',
  227. 'ezcWebdavKonquerorCompatibleTransport'
  228. ),
  229. 3 => new ezcWebdavServerConfiguration(),
  230. ),
  231. 'configurations',
  232. $dp,
  233. 'Default properties not created correctly on empty ctor.'
  234. );
  235. try
  236. {
  237. $dp->insertBefore( $secondCfg, 42 );
  238. $this->fail( 'ezcBaseValueException not thrown on wide to large int $offset.' );
  239. }
  240. catch ( ezcBaseValueException $e ) {}
  241. $this->assertAttributeEquals(
  242. array(
  243. 0 => new ezcWebdavServerConfiguration(
  244. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  245. 'ezcWebdavMicrosoftCompatibleTransport'
  246. ),
  247. 1 => new ezcWebdavServerConfiguration(
  248. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  249. 'ezcWebdavNautilusCompatibleTransport',
  250. 'ezcWebdavXmlTool',
  251. 'ezcWebdavNautilusPropertyHandler'
  252. ),
  253. 2 => new ezcWebdavServerConfiguration(
  254. '(Konqueror)i',
  255. 'ezcWebdavKonquerorCompatibleTransport'
  256. ),
  257. 3 => new ezcWebdavServerConfiguration(),
  258. ),
  259. 'configurations',
  260. $dp,
  261. 'Default properties not created correctly on empty ctor.'
  262. );
  263. try
  264. {
  265. $dp->insertBefore( $secondCfg, 4 );
  266. $this->fail( 'ezcBaseValueException not thrown on to large int $offset.' );
  267. }
  268. catch ( ezcBaseValueException $e ) {}
  269. $this->assertAttributeEquals(
  270. array(
  271. 0 => new ezcWebdavServerConfiguration(
  272. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  273. 'ezcWebdavMicrosoftCompatibleTransport'
  274. ),
  275. 1 => new ezcWebdavServerConfiguration(
  276. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  277. 'ezcWebdavNautilusCompatibleTransport',
  278. 'ezcWebdavXmlTool',
  279. 'ezcWebdavNautilusPropertyHandler'
  280. ),
  281. 2 => new ezcWebdavServerConfiguration(
  282. '(Konqueror)i',
  283. 'ezcWebdavKonquerorCompatibleTransport'
  284. ),
  285. 3 => new ezcWebdavServerConfiguration(),
  286. ),
  287. 'configurations',
  288. $dp,
  289. 'Default properties not created correctly on empty ctor.'
  290. );
  291. }
  292. public function testCreateTransportDefaultCtorSuccess()
  293. {
  294. $dp = new ezcWebdavServerConfigurationManager();
  295. $dp->configure( ezcWebdavServer::getInstance(), '' );
  296. $this->assertEquals(
  297. new ezcWebdavTransport(),
  298. ezcWebdavServer::getInstance()->transport
  299. );
  300. $dp->configure( ezcWebdavServer::getInstance(), 'Foo' );
  301. $this->assertEquals(
  302. new ezcWebdavTransport(),
  303. ezcWebdavServer::getInstance()->transport
  304. );
  305. $dp->configure( ezcWebdavServer::getInstance(), 'Nautilus' );
  306. $this->assertEquals(
  307. new ezcWebdavTransport(),
  308. ezcWebdavServer::getInstance()->transport
  309. );
  310. }
  311. public function testCreateTransportMultipleConfigsSuccess()
  312. {
  313. $dp = new ezcWebdavServerConfigurationManager();
  314. $ms = new ezcWebdavServerConfiguration( '(^.*micro\\$oft.*$)i' );
  315. $gn = new ezcWebdavServerConfiguration( '(^.*nautilus.*$)i', 'fooCustomTransport' );
  316. $kd = new ezcWebdavServerConfiguration( '(^.*konqueror.*$)i' );
  317. $ca = new ezcWebdavServerConfiguration( '(^.*cadaver.*$)i' );
  318. $dp->insertBefore( $ms, 0 );
  319. $dp->insertBefore( $gn, 0 );
  320. $dp->insertBefore( $kd, 0 );
  321. $dp->insertBefore( $ca, 0 );
  322. $dp->configure( ezcWebdavServer::getInstance(), '' );
  323. $this->assertEquals(
  324. new ezcWebdavTransport(),
  325. ezcWebdavServer::getInstance()->transport,
  326. 'Default transport not created on none-matching User-Agent.'
  327. );
  328. $dp->configure( ezcWebdavServer::getInstance(), 'Mirco$soft Internet Explorer 66.6beta1' );
  329. $this->assertEquals(
  330. new ezcWebdavTransport(),
  331. ezcWebdavServer::getInstance()->transport,
  332. 'Transport not correctly selected, $ms'
  333. );
  334. $dp->configure( ezcWebdavServer::getInstance(), 'Gentoo-2.6.22-r8, Gnome 2.18.2-rc2, Nautilus' );
  335. $this->assertEquals(
  336. new fooCustomTransport(),
  337. ezcWebdavServer::getInstance()->transport,
  338. 'Transport not correctly selected, $gn'
  339. );
  340. $dp->configure( ezcWebdavServer::getInstance(), 'Gentoo-2.6.22-r8, KDE Foo Bar, Konqueror-X.Y.Z, libneon-a.b.c-alpha23' );
  341. $this->assertEquals(
  342. new ezcWebdavTransport(),
  343. ezcWebdavServer::getInstance()->transport,
  344. 'Transport not correctly selected, $kd'
  345. );
  346. }
  347. public function testCreateTransportFailure()
  348. {
  349. $dp = new ezcWebdavServerConfigurationManager();
  350. unset( $dp[0] );
  351. unset( $dp[0] );
  352. unset( $dp[0] );
  353. unset( $dp[0] );
  354. try
  355. {
  356. $dp->configure( ezcWebdavServer::getInstance(), 'Fooo Bar' );
  357. $this->fail( 'Creating transport does not fail without any configs.' );
  358. }
  359. catch ( ezcWebdavMissingTransportConfigurationException $e ) {}
  360. $unmatching = new ezcWebdavServerConfiguration( '(^.*micro\$oft.*)i' );
  361. $dp[] = $unmatching;
  362. try
  363. {
  364. $dp->configure( ezcWebdavServer::getInstance(), 'Fooo Bar' );
  365. $this->fail( 'Creating transport does not fail without any configs.' );
  366. }
  367. catch ( ezcWebdavMissingTransportConfigurationException $e ) {}
  368. $dp->configure( ezcWebdavServer::getInstance(), 'some MiCrO$OfT client' );
  369. $this->assertEquals(
  370. new ezcWebdavTransport(),
  371. ezcWebdavServer::getInstance()->transport,
  372. 'Transport not created correctly with match.'
  373. );
  374. }
  375. public function testOffsetSetSuccess()
  376. {
  377. $first = new ezcWebdavServerConfiguration( '(a)' );
  378. $second = new ezcWebdavServerConfiguration( '(b)' );
  379. $dp = new ezcWebdavServerConfigurationManager();
  380. $dp[1] = $first;
  381. $dp[] = $second;
  382. $this->assertAttributeEquals(
  383. array(
  384. 0 => new ezcWebdavServerConfiguration(
  385. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  386. 'ezcWebdavMicrosoftCompatibleTransport'
  387. ),
  388. 1 => $first,
  389. 2 => new ezcWebdavServerConfiguration(
  390. '(Konqueror)i',
  391. 'ezcWebdavKonquerorCompatibleTransport'
  392. ),
  393. 3 => new ezcWebdavServerConfiguration(),
  394. 4 => $second,
  395. ),
  396. 'configurations',
  397. $dp,
  398. 'Configurations not added correctly through offsetSet().'
  399. );
  400. $dp[0] = $second;
  401. $this->assertAttributeEquals(
  402. array(
  403. 0 => $second,
  404. 1 => $first,
  405. 2 => new ezcWebdavServerConfiguration(
  406. '(Konqueror)i',
  407. 'ezcWebdavKonquerorCompatibleTransport'
  408. ),
  409. 3 => new ezcWebdavServerConfiguration(),
  410. 4 => $second,
  411. ),
  412. 'configurations',
  413. $dp,
  414. 'Configurations not added correctly through offsetSet().'
  415. );
  416. }
  417. public function testOffsetSetFailure()
  418. {
  419. $first = new ezcWebdavServerConfiguration( '(a)' );
  420. $second = new stdClass();
  421. $dp = new ezcWebdavServerConfigurationManager();
  422. try
  423. {
  424. $dp[5] = $first;
  425. $this->fail( 'ezcBaseValueException not thrown on set access with too large offset.' );
  426. }
  427. catch ( ezcBaseValueException $e ) {}
  428. $this->assertAttributeEquals(
  429. array(
  430. 0 => new ezcWebdavServerConfiguration(
  431. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  432. 'ezcWebdavMicrosoftCompatibleTransport'
  433. ),
  434. 1 => new ezcWebdavServerConfiguration(
  435. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  436. 'ezcWebdavNautilusCompatibleTransport',
  437. 'ezcWebdavXmlTool',
  438. 'ezcWebdavNautilusPropertyHandler'
  439. ),
  440. 2 => new ezcWebdavServerConfiguration(
  441. '(Konqueror)i',
  442. 'ezcWebdavKonquerorCompatibleTransport'
  443. ),
  444. 3 => new ezcWebdavServerConfiguration(),
  445. ),
  446. 'configurations',
  447. $dp,
  448. 'Configuration not added incorrectly through offsetSet().'
  449. );
  450. try
  451. {
  452. $dp[-2] = $first;
  453. $this->fail( 'ezcBaseValueException not thrown on set access with too small offset.' );
  454. }
  455. catch ( ezcBaseValueException $e ) {}
  456. $this->assertAttributeEquals(
  457. array(
  458. 0 => new ezcWebdavServerConfiguration(
  459. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  460. 'ezcWebdavMicrosoftCompatibleTransport'
  461. ),
  462. 1 => new ezcWebdavServerConfiguration(
  463. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  464. 'ezcWebdavNautilusCompatibleTransport',
  465. 'ezcWebdavXmlTool',
  466. 'ezcWebdavNautilusPropertyHandler'
  467. ),
  468. 2 => new ezcWebdavServerConfiguration(
  469. '(Konqueror)i',
  470. 'ezcWebdavKonquerorCompatibleTransport'
  471. ),
  472. 3 => new ezcWebdavServerConfiguration(),
  473. ),
  474. 'configurations',
  475. $dp,
  476. 'Configurations added in-correctly through offsetSet().'
  477. );
  478. try
  479. {
  480. $dp['foo'] = $first;
  481. $this->fail( 'ezcBaseValueException not thrown on set access with invalid offset.' );
  482. }
  483. catch ( ezcBaseValueException $e ) {}
  484. $this->assertAttributeEquals(
  485. array(
  486. 0 => new ezcWebdavServerConfiguration(
  487. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  488. 'ezcWebdavMicrosoftCompatibleTransport'
  489. ),
  490. 1 => new ezcWebdavServerConfiguration(
  491. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  492. 'ezcWebdavNautilusCompatibleTransport',
  493. 'ezcWebdavXmlTool',
  494. 'ezcWebdavNautilusPropertyHandler'
  495. ),
  496. 2 => new ezcWebdavServerConfiguration(
  497. '(Konqueror)i',
  498. 'ezcWebdavKonquerorCompatibleTransport'
  499. ),
  500. 3 => new ezcWebdavServerConfiguration(),
  501. ),
  502. 'configurations',
  503. $dp,
  504. 'Configurations added in-correctly through offsetSet().'
  505. );
  506. try
  507. {
  508. $dp[] = $second;
  509. $this->fail( 'ezcBaseValueException not thrown on set access with invalid value and null offset.' );
  510. }
  511. catch ( ezcBaseValueException $e ) {}
  512. $this->assertAttributeEquals(
  513. array(
  514. 0 => new ezcWebdavServerConfiguration(
  515. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  516. 'ezcWebdavMicrosoftCompatibleTransport'
  517. ),
  518. 1 => new ezcWebdavServerConfiguration(
  519. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  520. 'ezcWebdavNautilusCompatibleTransport',
  521. 'ezcWebdavXmlTool',
  522. 'ezcWebdavNautilusPropertyHandler'
  523. ),
  524. 2 => new ezcWebdavServerConfiguration(
  525. '(Konqueror)i',
  526. 'ezcWebdavKonquerorCompatibleTransport'
  527. ),
  528. 3 => new ezcWebdavServerConfiguration(),
  529. ),
  530. 'configurations',
  531. $dp,
  532. 'Configurations added in-correctly through offsetSet().'
  533. );
  534. try
  535. {
  536. $dp[] = $second;
  537. $this->fail( 'ezcBaseValueException not thrown on set access with invalid value and null offset.' );
  538. }
  539. catch ( ezcBaseValueException $e ) {}
  540. $this->assertAttributeEquals(
  541. array(
  542. 0 => new ezcWebdavServerConfiguration(
  543. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  544. 'ezcWebdavMicrosoftCompatibleTransport'
  545. ),
  546. 1 => new ezcWebdavServerConfiguration(
  547. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  548. 'ezcWebdavNautilusCompatibleTransport',
  549. 'ezcWebdavXmlTool',
  550. 'ezcWebdavNautilusPropertyHandler'
  551. ),
  552. 2 => new ezcWebdavServerConfiguration(
  553. '(Konqueror)i',
  554. 'ezcWebdavKonquerorCompatibleTransport'
  555. ),
  556. 3 => new ezcWebdavServerConfiguration(),
  557. ),
  558. 'configurations',
  559. $dp,
  560. 'Configurations added in-correctly through offsetSet().'
  561. );
  562. try
  563. {
  564. $dp[0] = $second;
  565. $this->fail( 'ezcBaseValueException not thrown on set access with invalid value and 0 offset.' );
  566. }
  567. catch ( ezcBaseValueException $e ) {}
  568. $this->assertAttributeEquals(
  569. array(
  570. 0 => new ezcWebdavServerConfiguration(
  571. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  572. 'ezcWebdavMicrosoftCompatibleTransport'
  573. ),
  574. 1 => new ezcWebdavServerConfiguration(
  575. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  576. 'ezcWebdavNautilusCompatibleTransport',
  577. 'ezcWebdavXmlTool',
  578. 'ezcWebdavNautilusPropertyHandler'
  579. ),
  580. 2 => new ezcWebdavServerConfiguration(
  581. '(Konqueror)i',
  582. 'ezcWebdavKonquerorCompatibleTransport'
  583. ),
  584. 3 => new ezcWebdavServerConfiguration(),
  585. ),
  586. 'configurations',
  587. $dp,
  588. 'Configurations added in-correctly through offsetSet().'
  589. );
  590. try
  591. {
  592. $dp[1] = $second;
  593. $this->fail( 'ezcBaseValueException not thrown on set access with invalid value and 1 offset.' );
  594. }
  595. catch ( ezcBaseValueException $e ) {}
  596. $this->assertAttributeEquals(
  597. array(
  598. 0 => new ezcWebdavServerConfiguration(
  599. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  600. 'ezcWebdavMicrosoftCompatibleTransport'
  601. ),
  602. 1 => new ezcWebdavServerConfiguration(
  603. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  604. 'ezcWebdavNautilusCompatibleTransport',
  605. 'ezcWebdavXmlTool',
  606. 'ezcWebdavNautilusPropertyHandler'
  607. ),
  608. 2 => new ezcWebdavServerConfiguration(
  609. '(Konqueror)i',
  610. 'ezcWebdavKonquerorCompatibleTransport'
  611. ),
  612. 3 => new ezcWebdavServerConfiguration(),
  613. ),
  614. 'configurations',
  615. $dp,
  616. 'Configurations not added correctly through offsetSet().'
  617. );
  618. }
  619. public function testOffsetGetSuccess()
  620. {
  621. $first = new ezcWebdavServerConfiguration( '(a)' );
  622. $second = new ezcWebdavServerConfiguration( '(b)' );
  623. $dp = new ezcWebdavServerConfigurationManager();
  624. $dp[1] = $first;
  625. $dp[] = $second;
  626. $this->assertAttributeEquals(
  627. array(
  628. 0 => new ezcWebdavServerConfiguration(
  629. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  630. 'ezcWebdavMicrosoftCompatibleTransport'
  631. ),
  632. 1 => $first,
  633. 2 => new ezcWebdavServerConfiguration(
  634. '(Konqueror)i',
  635. 'ezcWebdavKonquerorCompatibleTransport'
  636. ),
  637. 3 => new ezcWebdavServerConfiguration(),
  638. 4 => $second,
  639. ),
  640. 'configurations',
  641. $dp,
  642. 'Configurations not added correctly through offsetSet().'
  643. );
  644. $this->assertEquals(
  645. new ezcWebdavServerConfiguration(
  646. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  647. 'ezcWebdavMicrosoftCompatibleTransport'
  648. ),
  649. $dp[0],
  650. 'Index 0 not got correctly.'
  651. );
  652. $this->assertSame(
  653. $first,
  654. $dp[1],
  655. 'Index 1 not got correctly.'
  656. );
  657. $this->assertEquals(
  658. new ezcWebdavServerConfiguration(
  659. '(Konqueror)i',
  660. 'ezcWebdavKonquerorCompatibleTransport'
  661. ),
  662. $dp[2],
  663. 'Index 2 not got correctly.'
  664. );
  665. $this->assertEquals(
  666. new ezcWebdavServerConfiguration(),
  667. $dp[3],
  668. 'Index 2 not got correctly.'
  669. );
  670. $this->assertSame(
  671. $second,
  672. $dp[4],
  673. 'Index 3 not got correctly.'
  674. );
  675. }
  676. public function testOffsetGetFailure()
  677. {
  678. $first = new ezcWebdavServerConfiguration( '(a)' );
  679. $second = new stdClass();
  680. $dp = new ezcWebdavServerConfigurationManager();
  681. $this->assertNull(
  682. $dp[4],
  683. 'Offset 4 not null.'
  684. );
  685. $this->assertAttributeEquals(
  686. array(
  687. 0 => new ezcWebdavServerConfiguration(
  688. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  689. 'ezcWebdavMicrosoftCompatibleTransport'
  690. ),
  691. 1 => new ezcWebdavServerConfiguration(
  692. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  693. 'ezcWebdavNautilusCompatibleTransport',
  694. 'ezcWebdavXmlTool',
  695. 'ezcWebdavNautilusPropertyHandler'
  696. ),
  697. 2 => new ezcWebdavServerConfiguration(
  698. '(Konqueror)i',
  699. 'ezcWebdavKonquerorCompatibleTransport'
  700. ),
  701. 3 => new ezcWebdavServerConfiguration(),
  702. ),
  703. 'configurations',
  704. $dp,
  705. 'Configuration changed on too large offset.'
  706. );
  707. try
  708. {
  709. echo $dp[-2];
  710. $this->fail( 'ezcBaseValueException not thrown on get access with too small offset.' );
  711. }
  712. catch ( ezcBaseValueException $e ) {}
  713. $this->assertAttributeEquals(
  714. array(
  715. 0 => new ezcWebdavServerConfiguration(
  716. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  717. 'ezcWebdavMicrosoftCompatibleTransport'
  718. ),
  719. 1 => new ezcWebdavServerConfiguration(
  720. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  721. 'ezcWebdavNautilusCompatibleTransport',
  722. 'ezcWebdavXmlTool',
  723. 'ezcWebdavNautilusPropertyHandler'
  724. ),
  725. 2 => new ezcWebdavServerConfiguration(
  726. '(Konqueror)i',
  727. 'ezcWebdavKonquerorCompatibleTransport'
  728. ),
  729. 3 => new ezcWebdavServerConfiguration(),
  730. ),
  731. 'configurations',
  732. $dp,
  733. 'Configuration changed on negative offset.'
  734. );
  735. try
  736. {
  737. echo $dp['foo'];
  738. $this->fail( 'ezcBaseValueException not thrown on get access with invalid offset.' );
  739. }
  740. catch ( ezcBaseValueException $e ) {}
  741. $this->assertAttributeEquals(
  742. array(
  743. 0 => new ezcWebdavServerConfiguration(
  744. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  745. 'ezcWebdavMicrosoftCompatibleTransport'
  746. ),
  747. 1 => new ezcWebdavServerConfiguration(
  748. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  749. 'ezcWebdavNautilusCompatibleTransport',
  750. 'ezcWebdavXmlTool',
  751. 'ezcWebdavNautilusPropertyHandler'
  752. ),
  753. 2 => new ezcWebdavServerConfiguration(
  754. '(Konqueror)i',
  755. 'ezcWebdavKonquerorCompatibleTransport'
  756. ),
  757. 3 => new ezcWebdavServerConfiguration(),
  758. ),
  759. 'configurations',
  760. $dp,
  761. 'Configuration changed on string offset.'
  762. );
  763. }
  764. public function testOffsetUnsetSuccess()
  765. {
  766. $first = new ezcWebdavServerConfiguration( '(a)' );
  767. $second = new ezcWebdavServerConfiguration( '(b)' );
  768. $dp = new ezcWebdavServerConfigurationManager();
  769. $this->assertAttributeEquals(
  770. array(
  771. 0 => new ezcWebdavServerConfiguration(
  772. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  773. 'ezcWebdavMicrosoftCompatibleTransport'
  774. ),
  775. 1 => new ezcWebdavServerConfiguration(
  776. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  777. 'ezcWebdavNautilusCompatibleTransport',
  778. 'ezcWebdavXmlTool',
  779. 'ezcWebdavNautilusPropertyHandler'
  780. ),
  781. 2 => new ezcWebdavServerConfiguration(
  782. '(Konqueror)i',
  783. 'ezcWebdavKonquerorCompatibleTransport'
  784. ),
  785. 3 => new ezcWebdavServerConfiguration(),
  786. ),
  787. 'configurations',
  788. $dp,
  789. 'Configurations not created correctly in ctor.'
  790. );
  791. $dp[1] = $first;
  792. $this->assertAttributeEquals(
  793. array(
  794. 0 => new ezcWebdavServerConfiguration(
  795. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  796. 'ezcWebdavMicrosoftCompatibleTransport'
  797. ),
  798. 1 => $first,
  799. 2 => new ezcWebdavServerConfiguration(
  800. '(Konqueror)i',
  801. 'ezcWebdavKonquerorCompatibleTransport'
  802. ),
  803. 3 => new ezcWebdavServerConfiguration(),
  804. ),
  805. 'configurations',
  806. $dp,
  807. 'Configurations not added correctly through offsetSet(1).'
  808. );
  809. $dp[] = $second;
  810. $this->assertAttributeEquals(
  811. array(
  812. 0 => new ezcWebdavServerConfiguration(
  813. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  814. 'ezcWebdavMicrosoftCompatibleTransport'
  815. ),
  816. 1 => $first,
  817. 2 => new ezcWebdavServerConfiguration(
  818. '(Konqueror)i',
  819. 'ezcWebdavKonquerorCompatibleTransport'
  820. ),
  821. 3 => new ezcWebdavServerConfiguration(),
  822. 4 => $second,
  823. ),
  824. 'configurations',
  825. $dp,
  826. 'Configurations not added correctly through offsetSet(null).'
  827. );
  828. unset( $dp[1] );
  829. $this->assertAttributeEquals(
  830. array(
  831. 0 => new ezcWebdavServerConfiguration(
  832. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  833. 'ezcWebdavMicrosoftCompatibleTransport'
  834. ),
  835. 1 => new ezcWebdavServerConfiguration(
  836. '(Konqueror)i',
  837. 'ezcWebdavKonquerorCompatibleTransport'
  838. ),
  839. 2 => new ezcWebdavServerConfiguration(),
  840. 3 => $second,
  841. ),
  842. 'configurations',
  843. $dp,
  844. 'Configurations not removed from offset 1 correctly through offsetUnset().'
  845. );
  846. unset( $dp[1] );
  847. $this->assertAttributeEquals(
  848. array(
  849. 0 => new ezcWebdavServerConfiguration(
  850. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  851. 'ezcWebdavMicrosoftCompatibleTransport'
  852. ),
  853. 1 => new ezcWebdavServerConfiguration(),
  854. 2 => $second,
  855. ),
  856. 'configurations',
  857. $dp,
  858. 'Configurations not removed from offset 1 correctly through offsetUnset().'
  859. );
  860. unset( $dp[1] );
  861. $this->assertAttributeEquals(
  862. array(
  863. 0 => new ezcWebdavServerConfiguration(
  864. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  865. 'ezcWebdavMicrosoftCompatibleTransport'
  866. ),
  867. 1 => $second,
  868. ),
  869. 'configurations',
  870. $dp,
  871. 'Configurations not removed from offset 1 correctly through offsetUnset().'
  872. );
  873. unset( $dp[1] );
  874. $this->assertAttributeEquals(
  875. array(
  876. 0 => new ezcWebdavServerConfiguration(
  877. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  878. 'ezcWebdavMicrosoftCompatibleTransport'
  879. ),
  880. ),
  881. 'configurations',
  882. $dp,
  883. 'Configurations not removed from offset 1 correctly through offsetUnset().'
  884. );
  885. unset( $dp[0] );
  886. $this->assertAttributeEquals(
  887. array(
  888. ),
  889. 'configurations',
  890. $dp,
  891. 'Configurations not removed from offset 0 correctly through offsetUnset().'
  892. );
  893. }
  894. public function testOffsetUnsetFailure()
  895. {
  896. $first = new ezcWebdavServerConfiguration( '(a)' );
  897. $second = new stdClass();
  898. $dp = new ezcWebdavServerConfigurationManager();
  899. unset( $dp[3] );
  900. $this->assertNull(
  901. $dp[3],
  902. 'Offset 3 not null.'
  903. );
  904. $this->assertAttributeEquals(
  905. array(
  906. 0 => new ezcWebdavServerConfiguration(
  907. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  908. 'ezcWebdavMicrosoftCompatibleTransport'
  909. ),
  910. 1 => new ezcWebdavServerConfiguration(
  911. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  912. 'ezcWebdavNautilusCompatibleTransport',
  913. 'ezcWebdavXmlTool',
  914. 'ezcWebdavNautilusPropertyHandler'
  915. ),
  916. 2 => new ezcWebdavServerConfiguration(
  917. '(Konqueror)i',
  918. 'ezcWebdavKonquerorCompatibleTransport'
  919. ),
  920. ),
  921. 'configurations',
  922. $dp,
  923. 'Configurations not added correctly through offsetSet().'
  924. );
  925. try
  926. {
  927. unset( $dp[-2] );
  928. $this->fail( 'ezcBaseValueException not thrown on unset access with too small offset.' );
  929. }
  930. catch ( ezcBaseValueException $e ) {}
  931. $this->assertAttributeEquals(
  932. array(
  933. 0 => new ezcWebdavServerConfiguration(
  934. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  935. 'ezcWebdavMicrosoftCompatibleTransport'
  936. ),
  937. 1 => new ezcWebdavServerConfiguration(
  938. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  939. 'ezcWebdavNautilusCompatibleTransport',
  940. 'ezcWebdavXmlTool',
  941. 'ezcWebdavNautilusPropertyHandler'
  942. ),
  943. 2 => new ezcWebdavServerConfiguration(
  944. '(Konqueror)i',
  945. 'ezcWebdavKonquerorCompatibleTransport'
  946. ),
  947. ),
  948. 'configurations',
  949. $dp,
  950. 'Configurations not added correctly through offsetSet().'
  951. );
  952. try
  953. {
  954. unset( $dp['foo'] );
  955. $this->fail( 'ezcBaseValueException not thrown on unset access with invalid offset.' );
  956. }
  957. catch ( ezcBaseValueException $e ) {}
  958. $this->assertAttributeEquals(
  959. array(
  960. 0 => new ezcWebdavServerConfiguration(
  961. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  962. 'ezcWebdavMicrosoftCompatibleTransport'
  963. ),
  964. 1 => new ezcWebdavServerConfiguration(
  965. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  966. 'ezcWebdavNautilusCompatibleTransport',
  967. 'ezcWebdavXmlTool',
  968. 'ezcWebdavNautilusPropertyHandler'
  969. ),
  970. 2 => new ezcWebdavServerConfiguration(
  971. '(Konqueror)i',
  972. 'ezcWebdavKonquerorCompatibleTransport'
  973. ),
  974. ),
  975. 'configurations',
  976. $dp,
  977. 'Configurations not added correctly through offsetSet().'
  978. );
  979. }
  980. public function testOffsetExistsSuccess()
  981. {
  982. $first = new ezcWebdavServerConfiguration( '(a)' );
  983. $second = new ezcWebdavServerConfiguration( '(b)' );
  984. $dp = new ezcWebdavServerConfigurationManager();
  985. $dp[1] = $first;
  986. $dp[] = $second;
  987. $this->assertAttributeEquals(
  988. array(
  989. 0 => new ezcWebdavServerConfiguration(
  990. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  991. 'ezcWebdavMicrosoftCompatibleTransport'
  992. ),
  993. 1 => $first,
  994. 2 => new ezcWebdavServerConfiguration(
  995. '(Konqueror)i',
  996. 'ezcWebdavKonquerorCompatibleTransport'
  997. ),
  998. 3 => new ezcWebdavServerConfiguration(),
  999. 4 => $second,
  1000. ),
  1001. 'configurations',
  1002. $dp,
  1003. 'Configurations not added correctly through offsetSet().'
  1004. );
  1005. $this->assertTrue(
  1006. isset( $dp[0] ),
  1007. 'Offset 0 does not seem to be set.'
  1008. );
  1009. $this->assertTrue(
  1010. isset( $dp[1] ),
  1011. 'Offset 1 does not seem to be set.'
  1012. );
  1013. $this->assertTrue(
  1014. isset( $dp[2] ),
  1015. 'Offset 2 does not seem to be set.'
  1016. );
  1017. $this->assertTrue(
  1018. isset( $dp[3] ),
  1019. 'Offset 3 does not seem to be set.'
  1020. );
  1021. $this->assertTrue(
  1022. isset( $dp[4] ),
  1023. 'Offset 4 does not seem to be set.'
  1024. );
  1025. }
  1026. public function testOffsetExistsFailure()
  1027. {
  1028. $first = new ezcWebdavServerConfiguration( '(a)' );
  1029. $second = new ezcWebdavServerConfiguration( '(b)' );
  1030. $dp = new ezcWebdavServerConfigurationManager();
  1031. $dp[1] = $first;
  1032. $dp[] = $second;
  1033. $this->assertAttributeEquals(
  1034. array(
  1035. 0 => new ezcWebdavServerConfiguration(
  1036. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  1037. 'ezcWebdavMicrosoftCompatibleTransport'
  1038. ),
  1039. 1 => $first,
  1040. 2 => new ezcWebdavServerConfiguration(
  1041. '(Konqueror)i',
  1042. 'ezcWebdavKonquerorCompatibleTransport'
  1043. ),
  1044. 3 => new ezcWebdavServerConfiguration(),
  1045. 4 => $second,
  1046. ),
  1047. 'configurations',
  1048. $dp,
  1049. 'Configurations not added correctly through offsetSet().'
  1050. );
  1051. $this->assertFalse(
  1052. isset( $dp[-1] ),
  1053. 'Offset -1 does seem to be set.'
  1054. );
  1055. $this->assertFalse(
  1056. isset( $dp[5] ),
  1057. 'Offset 3 does seem to be set.'
  1058. );
  1059. $this->assertFalse(
  1060. isset( $dp['foo'] ),
  1061. 'Offset "foo" does seem to be set.'
  1062. );
  1063. }
  1064. public function testIteratorDefaultCtor()
  1065. {
  1066. $dp = new ezcWebdavServerConfigurationManager();
  1067. $fake = array(
  1068. 0 => new ezcWebdavServerConfiguration(
  1069. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  1070. 'ezcWebdavMicrosoftCompatibleTransport'
  1071. ),
  1072. 1 => new ezcWebdavServerConfiguration(
  1073. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  1074. 'ezcWebdavNautilusCompatibleTransport',
  1075. 'ezcWebdavXmlTool',
  1076. 'ezcWebdavNautilusPropertyHandler'
  1077. ),
  1078. 2 => new ezcWebdavServerConfiguration(
  1079. '(Konqueror)i',
  1080. 'ezcWebdavKonquerorCompatibleTransport'
  1081. ),
  1082. 3 => new ezcWebdavServerConfiguration(),
  1083. );
  1084. $i = 0;
  1085. foreach( $dp as $key => $val )
  1086. {
  1087. $this->assertEquals(
  1088. $i,
  1089. $key,
  1090. "ID missmatch during iteration"
  1091. );
  1092. $this->assertTrue(
  1093. isset( $fake[$key] ),
  1094. "Fake key '$key' not set"
  1095. );
  1096. $this->assertEquals(
  1097. $fake[$key],
  1098. $val,
  1099. 'Value missmatch'
  1100. );
  1101. ++$i;
  1102. }
  1103. // Try if rewind works
  1104. $i = 0;
  1105. foreach( $dp as $key => $val )
  1106. {
  1107. $this->assertEquals(
  1108. $i,
  1109. $key,
  1110. "ID missmatch during iteration"
  1111. );
  1112. $this->assertTrue(
  1113. isset( $fake[$key] ),
  1114. "Fake key '$key' not set"
  1115. );
  1116. $this->assertEquals(
  1117. $fake[$key],
  1118. $val,
  1119. 'Value missmatch'
  1120. );
  1121. ++$i;
  1122. }
  1123. }
  1124. public function testIteratorMultipleElements()
  1125. {
  1126. $dp = new ezcWebdavServerConfigurationManager();
  1127. $dp[] = new ezcWebdavServerConfiguration( '(.*nautilus.*)i' );
  1128. $dp[] = new ezcWebdavServerConfiguration( '(.*konqueror.*)i' );
  1129. $fake = array(
  1130. 0 => new ezcWebdavServerConfiguration(
  1131. '(Microsoft\s+Data\s+Access|MSIE|MiniRedir)i',
  1132. 'ezcWebdavMicrosoftCompatibleTransport'
  1133. ),
  1134. 1 => new ezcWebdavServerConfiguration(
  1135. '(gnome-vfs/[0-9.]+ neon/[0-9.]*|gvfs/[0-9.]+)i',
  1136. 'ezcWebdavNautilusCompatibleTransport',
  1137. 'ezcWebdavXmlTool',
  1138. 'ezcWebdavNautilusPropertyHandler'
  1139. ),
  1140. 2 => new ezcWebdavServerConfiguration(
  1141. '(Konqueror)i',
  1142. 'ezcWebdavKonquerorCompatibleTransport'
  1143. ),
  1144. 3 => new ezcWebdavServerConfiguration(),
  1145. 4 => new ezcWebdavServerConfiguration( '(.*nautilus.*)i' ),
  1146. 5 => new ezcWebdavServerConfiguration( '(.*konqueror.*)i' ),
  1147. );
  1148. $i = 0;
  1149. foreach( $dp as $key => $val )
  1150. {
  1151. $this->assertEquals(
  1152. $i,
  1153. $key,
  1154. "ID missmatch during iteration"
  1155. );
  1156. $this->assertTrue(
  1157. isset( $fake[$key] ),
  1158. "Fake key '$key' not set"
  1159. );
  1160. $this->assertEquals(
  1161. $fake[$key],
  1162. $val,
  1163. 'Value missmatch'
  1164. );
  1165. ++$i;
  1166. }
  1167. // Try if rewind works
  1168. $i = 0;
  1169. foreach( $dp as $key => $val )
  1170. {
  1171. $this->assertEquals(
  1172. $i,
  1173. $key,
  1174. "ID missmatch during iteration"
  1175. );
  1176. $this->assertTrue(
  1177. isset( $fake[$key] ),
  1178. "Fake key '$key' not set"
  1179. );
  1180. $this->assertEquals(
  1181. $fake[$key],
  1182. $val,
  1183. 'Value missmatch'
  1184. );
  1185. ++$i;
  1186. }
  1187. }
  1188. public function testIteratorEmpty()
  1189. {
  1190. $dp = new ezcWebdavServerConfigurationManager();
  1191. unset( $dp[0] );
  1192. unset( $dp[0] );
  1193. unset( $dp[0] );
  1194. unset( $dp[0] );
  1195. $fake = array();
  1196. $i = 0;
  1197. foreach( $dp as $key => $val )
  1198. {
  1199. $this->assertEquals(
  1200. $i,
  1201. $key,
  1202. "ID missmatch during iteration"
  1203. );
  1204. $this->assertTrue(
  1205. isset( $fake[$key] ),
  1206. "Fake key '$key' not set"
  1207. );
  1208. $this->assertEquals(
  1209. $fake[$key],
  1210. $val,
  1211. 'Value missmatch'
  1212. );
  1213. ++$i;
  1214. }
  1215. // Try if rewind works
  1216. $i = 0;
  1217. foreach( $dp as $key => $val )
  1218. {
  1219. $this->assertEquals(
  1220. $i,
  1221. $key,
  1222. "ID missmatch during iteration"
  1223. );
  1224. $this->assertTrue(
  1225. isset( $fake[$key] ),
  1226. "Fake key '$key' not set"
  1227. );
  1228. $this->assertEquals(
  1229. $fake[$key],
  1230. $val,
  1231. 'Value missmatch'
  1232. );
  1233. ++$i;
  1234. }
  1235. }
  1236. }
  1237. ?>