MaildirWritableTest.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  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_Mail
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2010 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. /**
  23. * Zend_Mail_Storage_Folder_Maildir
  24. */
  25. require_once 'Zend/Mail/Storage/Writable/Maildir.php';
  26. /**
  27. * PHPUnit test case
  28. */
  29. require_once 'PHPUnit/Framework/TestCase.php';
  30. /**
  31. * @category Zend
  32. * @package Zend_Mail
  33. * @subpackage UnitTests
  34. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  35. * @license http://framework.zend.com/license/new-bsd New BSD License
  36. * @group Zend_Mail
  37. */
  38. class Zend_Mail_MaildirWritableTest extends PHPUnit_Framework_TestCase
  39. {
  40. protected $_params;
  41. protected $_originalDir;
  42. protected $_tmpdir;
  43. protected $_subdirs = array('.', '.subfolder', '.subfolder.test');
  44. public function setUp()
  45. {
  46. $this->_originalDir = dirname(__FILE__) . '/_files/test.maildir/';
  47. if (!is_dir($this->_originalDir . '/cur/')) {
  48. $this->markTestSkipped('You have to unpack maildir.tar in Zend/Mail/_files/test.maildir/ '
  49. . 'directory before enabling the maildir tests');
  50. return;
  51. }
  52. if ($this->_tmpdir == null) {
  53. if (TESTS_ZEND_MAIL_TEMPDIR != null) {
  54. $this->_tmpdir = TESTS_ZEND_MAIL_TEMPDIR;
  55. } else {
  56. $this->_tmpdir = dirname(__FILE__) . '/_files/test.tmp/';
  57. }
  58. if (!file_exists($this->_tmpdir)) {
  59. mkdir($this->_tmpdir);
  60. }
  61. $count = 0;
  62. $dh = opendir($this->_tmpdir);
  63. while (readdir($dh) !== false) {
  64. ++$count;
  65. }
  66. closedir($dh);
  67. if ($count != 2) {
  68. $this->markTestSkipped('Are you sure your tmp dir is a valid empty dir?');
  69. return;
  70. }
  71. }
  72. $this->_params = array();
  73. $this->_params['dirname'] = $this->_tmpdir;
  74. foreach ($this->_subdirs as $dir) {
  75. if ($dir != '.') {
  76. mkdir($this->_tmpdir . $dir);
  77. }
  78. foreach (array('cur', 'new') as $subdir) {
  79. if (!file_exists($this->_originalDir . $dir . '/' . $subdir)) {
  80. continue;
  81. }
  82. mkdir($this->_tmpdir . $dir . '/' . $subdir);
  83. $dh = opendir($this->_originalDir . $dir . '/' . $subdir);
  84. while (($entry = readdir($dh)) !== false) {
  85. $entry = $dir . '/' . $subdir . '/' . $entry;
  86. if (!is_file($this->_originalDir . $entry)) {
  87. continue;
  88. }
  89. copy($this->_originalDir . $entry, $this->_tmpdir . $entry);
  90. }
  91. closedir($dh);
  92. }
  93. copy($this->_originalDir . 'maildirsize', $this->_tmpdir . 'maildirsize');
  94. }
  95. }
  96. public function tearDown()
  97. {
  98. foreach (array_reverse($this->_subdirs) as $dir) {
  99. if (!file_exists($this->_tmpdir . $dir)) {
  100. continue;
  101. }
  102. foreach (array('cur', 'new', 'tmp') as $subdir) {
  103. if (!file_exists($this->_tmpdir . $dir . '/' . $subdir)) {
  104. continue;
  105. }
  106. $dh = opendir($this->_tmpdir . $dir . '/' . $subdir);
  107. while (($entry = readdir($dh)) !== false) {
  108. $entry = $this->_tmpdir . $dir . '/' . $subdir . '/' . $entry;
  109. if (!is_file($entry)) {
  110. continue;
  111. }
  112. unlink($entry);
  113. }
  114. closedir($dh);
  115. rmdir($this->_tmpdir . $dir . '/' . $subdir);
  116. }
  117. if ($dir != '.') {
  118. rmdir($this->_tmpdir . $dir);
  119. }
  120. }
  121. @unlink($this->_tmpdir . 'maildirsize');
  122. }
  123. public function testCreateFolder()
  124. {
  125. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  126. $mail->createFolder('subfolder.test1');
  127. $mail->createFolder('test2', 'INBOX.subfolder');
  128. $mail->createFolder('test3', $mail->getFolders()->subfolder);
  129. $mail->createFolder('foo.bar');
  130. try {
  131. $mail->selectFolder($mail->getFolders()->subfolder->test1);
  132. $mail->selectFolder($mail->getFolders()->subfolder->test2);
  133. $mail->selectFolder($mail->getFolders()->subfolder->test3);
  134. $mail->selectFolder($mail->getFolders()->foo->bar);
  135. } catch (Exception $e) {
  136. $this->fail('could not get new folders');
  137. }
  138. // to tear down
  139. $this->_subdirs[] = '.subfolder.test1';
  140. $this->_subdirs[] = '.subfolder.test2';
  141. $this->_subdirs[] = '.subfolder.test3';
  142. $this->_subdirs[] = '.foo';
  143. $this->_subdirs[] = '.foo.bar';
  144. }
  145. public function testCreateFolderEmtpyPart()
  146. {
  147. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  148. try {
  149. $mail->createFolder('foo..bar');
  150. } catch (Exception $e) {
  151. return; //ok
  152. }
  153. $this->fail('no exception while creating folder with empty part name');
  154. }
  155. public function testCreateFolderSlash()
  156. {
  157. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  158. try {
  159. $mail->createFolder('foo/bar');
  160. } catch (Exception $e) {
  161. return; //ok
  162. }
  163. $this->fail('no exception while creating folder with slash');
  164. }
  165. public function testCreateFolderDirectorySeparator()
  166. {
  167. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  168. try {
  169. $mail->createFolder('foo' . DIRECTORY_SEPARATOR . 'bar');
  170. } catch (Exception $e) {
  171. return; //ok
  172. }
  173. $this->fail('no exception while creating folder with DIRECTORY_SEPARATOR');
  174. }
  175. public function testCreateFolderExistingDir()
  176. {
  177. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  178. unset($mail->getFolders()->subfolder->test);
  179. try {
  180. $mail->createFolder('subfolder.test');
  181. } catch (Exception $e) {
  182. return; // ok
  183. }
  184. $this->fail('should not be able to create existing folder');
  185. }
  186. public function testCreateExistingFolder()
  187. {
  188. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  189. try {
  190. $mail->createFolder('subfolder.test');
  191. } catch (Exception $e) {
  192. return; // ok
  193. }
  194. $this->fail('should not be able to create existing folder');
  195. }
  196. public function testRemoveFolderName()
  197. {
  198. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  199. $mail->removeFolder('INBOX.subfolder.test');
  200. try {
  201. $mail->selectFolder($mail->getFolders()->subfolder->test);
  202. } catch (Exception $e) {
  203. return; // ok
  204. }
  205. $this->fail('folder still exists');
  206. }
  207. public function testRemoveFolderInstance()
  208. {
  209. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  210. $mail->removeFolder($mail->getFolders()->subfolder->test);
  211. try {
  212. $mail->selectFolder($mail->getFolders()->subfolder->test);
  213. } catch (Exception $e) {
  214. return; // ok
  215. }
  216. $this->fail('folder still exists');
  217. }
  218. public function testRemoveFolderWithChildren()
  219. {
  220. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  221. try {
  222. $mail->removeFolder($mail->getFolders()->subfolder);
  223. } catch (Exception $e) {
  224. return; // ok
  225. }
  226. $this->fail('should not be able to remove a folder with children');
  227. }
  228. public function testRemoveSelectedFolder()
  229. {
  230. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  231. $mail->selectFolder('subfolder.test');
  232. try {
  233. $mail->removeFolder('subfolder.test');
  234. } catch (Exception $e) {
  235. return; // ok
  236. }
  237. $this->fail('no error while removing selected folder');
  238. }
  239. public function testRemoveInvalidFolder()
  240. {
  241. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  242. try {
  243. $mail->removeFolder('thisFolderDoestNotExist');
  244. } catch (Exception $e) {
  245. return; // ok
  246. }
  247. $this->fail('no error while removing invalid folder');
  248. }
  249. public function testRenameFolder()
  250. {
  251. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  252. try {
  253. $mail->renameFolder('INBOX.subfolder', 'INBOX.foo');
  254. $mail->renameFolder($mail->getFolders()->foo, 'subfolder');
  255. } catch (Exception $e) {
  256. $this->fail('renaming failed');
  257. }
  258. try {
  259. $mail->renameFolder('INBOX', 'foo');
  260. } catch (Exception $e) {
  261. return; // ok
  262. }
  263. $this->fail('no error while renaming INBOX');
  264. }
  265. public function testRenameSelectedFolder()
  266. {
  267. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  268. $mail->selectFolder('subfolder.test');
  269. try {
  270. $mail->renameFolder('subfolder.test', 'foo');
  271. } catch (Exception $e) {
  272. return; // ok
  273. }
  274. $this->fail('no error while renaming selected folder');
  275. }
  276. public function testRenameToChild()
  277. {
  278. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  279. try {
  280. $mail->renameFolder('subfolder.test', 'subfolder.test.foo');
  281. } catch (Exception $e) {
  282. return; // ok
  283. }
  284. $this->fail('no error while renaming folder to child of old');
  285. }
  286. public function testAppend()
  287. {
  288. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  289. $count = $mail->countMessages();
  290. $message = '';
  291. $message .= "From: me@example.org\r\n";
  292. $message .= "To: you@example.org\r\n";
  293. $message .= "Subject: append test\r\n";
  294. $message .= "\r\n";
  295. $message .= "This is a test\r\n";
  296. $mail->appendMessage($message);
  297. $this->assertEquals($count + 1, $mail->countMessages());
  298. $this->assertEquals($mail->getMessage($count + 1)->subject, 'append test');
  299. }
  300. public function testCopy()
  301. {
  302. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  303. $mail->selectFolder('subfolder.test');
  304. $count = $mail->countMessages();
  305. $mail->selectFolder('INBOX');
  306. $message = $mail->getMessage(1);
  307. $mail->copyMessage(1, 'subfolder.test');
  308. $mail->selectFolder('subfolder.test');
  309. $this->assertEquals($count + 1, $mail->countMessages());
  310. $this->assertEquals($mail->getMessage($count + 1)->subject, $message->subject);
  311. $this->assertEquals($mail->getMessage($count + 1)->from, $message->from);
  312. $this->assertEquals($mail->getMessage($count + 1)->to, $message->to);
  313. try {
  314. $mail->copyMessage(1, 'justARandomFolder');
  315. } catch (Exception $e) {
  316. return; // ok
  317. }
  318. $this->fail('no error while copying to wrong folder');
  319. }
  320. public function testSetFlags()
  321. {
  322. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  323. $mail->setFlags(1, array(Zend_Mail_Storage::FLAG_SEEN));
  324. $message = $mail->getMessage(1);
  325. $this->assertTrue($message->hasFlag(Zend_Mail_Storage::FLAG_SEEN));
  326. $this->assertFalse($message->hasFlag(Zend_Mail_Storage::FLAG_FLAGGED));
  327. $mail->setFlags(1, array(Zend_Mail_Storage::FLAG_SEEN, Zend_Mail_Storage::FLAG_FLAGGED));
  328. $message = $mail->getMessage(1);
  329. $this->assertTrue($message->hasFlag(Zend_Mail_Storage::FLAG_SEEN));
  330. $this->assertTrue($message->hasFlag(Zend_Mail_Storage::FLAG_FLAGGED));
  331. $mail->setFlags(1, array(Zend_Mail_Storage::FLAG_FLAGGED));
  332. $message = $mail->getMessage(1);
  333. $this->assertFalse($message->hasFlag(Zend_Mail_Storage::FLAG_SEEN));
  334. $this->assertTrue($message->hasFlag(Zend_Mail_Storage::FLAG_FLAGGED));
  335. try {
  336. $mail->setFlags(1, array(Zend_Mail_Storage::FLAG_RECENT));
  337. } catch (Exception $e) {
  338. return; // ok
  339. }
  340. $this->fail('should not be able to set recent flag');
  341. }
  342. public function testSetFlagsRemovedFile()
  343. {
  344. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  345. unlink($this->_params['dirname'] . 'cur/1000000000.P1.example.org:2,S');
  346. try {
  347. $mail->setFlags(1, array(Zend_Mail_Storage::FLAG_FLAGGED));
  348. } catch (Exception $e) {
  349. return; // ok
  350. }
  351. $this->fail('should not be able to set flags with removed file');
  352. }
  353. public function testRemove()
  354. {
  355. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  356. $count = $mail->countMessages();
  357. $mail->removeMessage(1);
  358. $this->assertEquals($mail->countMessages(), --$count);
  359. unset($mail[2]);
  360. $this->assertEquals($mail->countMessages(), --$count);
  361. }
  362. public function testRemoveRemovedFile()
  363. {
  364. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  365. unlink($this->_params['dirname'] . 'cur/1000000000.P1.example.org:2,S');
  366. try {
  367. $mail->removeMessage(1);
  368. } catch (Exception $e) {
  369. return; // ok
  370. }
  371. $this->fail('should not be able to remove message which is already removed in fs');
  372. }
  373. public function testCheckQuota()
  374. {
  375. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  376. $this->assertFalse($mail->checkQuota());
  377. }
  378. public function testCheckQuotaDetailed()
  379. {
  380. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  381. $quotaResult = array(
  382. 'size' => 2596,
  383. 'count' => 6,
  384. 'quota' => array(
  385. 'count' => 10,
  386. 'L' => 1,
  387. 'size' => 3000
  388. ),
  389. 'over_quota' => false
  390. );
  391. $this->assertEquals($mail->checkQuota(true), $quotaResult);
  392. }
  393. public function testSetQuota()
  394. {
  395. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  396. $this->assertNull($mail->getQuota());
  397. $mail->setQuota(true);
  398. $this->assertTrue($mail->getQuota());
  399. $mail->setQuota(false);
  400. $this->assertFalse($mail->getQuota());
  401. $mail->setQuota(array('size' => 100, 'count' => 2, 'X' => 0));
  402. $this->assertEquals($mail->getQuota(), array('size' => 100, 'count' => 2, 'X' => 0));
  403. $this->assertEquals($mail->getQuota(true), array('size' => 3000, 'L' => 1, 'count' => 10));
  404. $quotaResult = array(
  405. 'size' => 2596,
  406. 'count' => 6,
  407. 'quota' => array(
  408. 'size' => 100,
  409. 'count' => 2,
  410. 'X' => 0
  411. ),
  412. 'over_quota' => true
  413. );
  414. $this->assertEquals($mail->checkQuota(true, true), $quotaResult);
  415. $this->assertEquals($mail->getQuota(true), array('size' => 100, 'count' => 2, 'X' => 0));
  416. }
  417. public function testMissingMaildirsize()
  418. {
  419. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  420. $this->assertEquals($mail->getQuota(true), array('size' => 3000, 'L' => 1, 'count' => 10));
  421. unlink($this->_tmpdir . 'maildirsize');
  422. $this->assertNull($mail->getQuota());
  423. try {
  424. $mail->getQuota(true);
  425. } catch(Zend_Mail_Exception $e) {
  426. // ok
  427. return;
  428. }
  429. $this->fail('get quota from file should fail if file is missing');
  430. }
  431. public function testMissingMaildirsizeWithFixedQuota()
  432. {
  433. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  434. unlink($this->_tmpdir . 'maildirsize');
  435. $mail->setQuota(array('size' => 100, 'count' => 2, 'X' => 0));
  436. $quotaResult = array(
  437. 'size' => 2596,
  438. 'count' => 6,
  439. 'quota' => array(
  440. 'size' => 100,
  441. 'count' => 2,
  442. 'X' => 0
  443. ),
  444. 'over_quota' => true
  445. );
  446. $this->assertEquals($mail->checkQuota(true), $quotaResult);
  447. $this->assertEquals($mail->getQuota(true), $quotaResult['quota']);
  448. }
  449. public function testAppendMessage()
  450. {
  451. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  452. $mail->setQuota(array('size' => 3000, 'count' => 6, 'X' => 0));
  453. $this->assertFalse($mail->checkQuota(false, true));
  454. $mail->appendMessage("Subject: test\r\n\r\n");
  455. $quotaResult = array(
  456. 'size' => 2613,
  457. 'count' => 7,
  458. 'quota' => array(
  459. 'size' => 3000,
  460. 'count' => 6,
  461. 'X' => 0
  462. ),
  463. 'over_quota' => true
  464. );
  465. $this->assertEquals($mail->checkQuota(true), $quotaResult);
  466. $mail->setQuota(false);
  467. $this->assertTrue($mail->checkQuota());
  468. try {
  469. $mail->appendMessage("Subject: test\r\n\r\n");
  470. } catch(Zend_Mail_Exception $e) {
  471. $this->fail('appending should not fail if quota check is not active');
  472. }
  473. $mail->setQuota(true);
  474. $this->assertTrue($mail->checkQuota());
  475. try {
  476. $mail->appendMessage("Subject: test\r\n\r\n");
  477. } catch(Zend_Mail_Exception $e) {
  478. // ok
  479. return;
  480. }
  481. $this->fail('appending after being over quota should fail');
  482. }
  483. public function testRemoveMessage()
  484. {
  485. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  486. $mail->setQuota(array('size' => 3000, 'count' => 5, 'X' => 0));
  487. $this->assertTrue($mail->checkQuota(false, true));
  488. $mail->removeMessage(1);
  489. $this->assertFalse($mail->checkQuota());
  490. }
  491. public function testCopyMessage()
  492. {
  493. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  494. $mail->setQuota(array('size' => 3000, 'count' => 6, 'X' => 0));
  495. $this->assertFalse($mail->checkQuota(false, true));
  496. $mail->copyMessage(1, 'subfolder');
  497. $quotaResult = array(
  498. 'size' => 2993,
  499. 'count' => 7,
  500. 'quota' => array(
  501. 'size' => 3000,
  502. 'count' => 6,
  503. 'X' => 0
  504. ),
  505. 'over_quota' => true
  506. );
  507. $this->assertEquals($mail->checkQuota(true), $quotaResult);
  508. }
  509. public function testAppendStream()
  510. {
  511. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  512. $fh = fopen('php://memory', 'rw');
  513. fputs($fh, "Subject: test\r\n\r\n");
  514. fseek($fh, 0);
  515. $mail->appendMessage($fh);
  516. fclose($fh);
  517. $this->assertEquals($mail->getMessage($mail->countMessages())->subject, 'test');
  518. }
  519. public function testMove()
  520. {
  521. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  522. $target = $mail->getFolders()->subfolder->test;
  523. $mail->selectFolder($target);
  524. $toCount = $mail->countMessages();
  525. $mail->selectFolder('INBOX');
  526. $fromCount = $mail->countMessages();
  527. $mail->moveMessage(1, $target);
  528. $this->assertEquals($fromCount - 1, $mail->countMessages());
  529. $mail->selectFolder($target);
  530. $this->assertEquals($toCount + 1, $mail->countMessages());
  531. }
  532. public function testInitExisting()
  533. {
  534. // this should be a noop
  535. Zend_Mail_Storage_Writable_Maildir::initMaildir($this->_params['dirname']);
  536. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  537. $this->assertEquals($mail->countMessages(), 5);
  538. }
  539. public function testInit()
  540. {
  541. $this->tearDown();
  542. // should fail now
  543. $e = null;
  544. try {
  545. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  546. } catch (Exception $e) {
  547. }
  548. if ($e === null) {
  549. $this->fail('empty maildir should not be accepted');
  550. }
  551. Zend_Mail_Storage_Writable_Maildir::initMaildir($this->_params['dirname']);
  552. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  553. $this->assertEquals($mail->countMessages(), 0);
  554. }
  555. public function testCreate()
  556. {
  557. $this->tearDown();
  558. // should fail now
  559. $e = null;
  560. try {
  561. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  562. } catch (Exception $e) {
  563. }
  564. if ($e === null) {
  565. $this->fail('empty maildir should not be accepted');
  566. }
  567. $this->_params['create'] = true;
  568. $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params);
  569. $this->assertEquals($mail->countMessages(), 0);
  570. }
  571. }