Overview

Namespaces

  • Jyxo
    • Beholder
      • TestCase
    • Gettext
      • Parser
    • Input
      • Chain
      • Filter
      • Validator
    • Mail
      • Email
        • Attachment
      • Parser
      • Sender
    • Rpc
      • Json
      • Xml
    • Shell
    • Spl
    • Svn
    • Time
    • Webdav
  • PHP

Classes

  • FileSystem
  • HttpResponse
  • Imap
  • JsonRpc
  • Memcached
  • Mysql
  • Pgsql
  • PhpExtension
  • PhpVersion
  • PhpZend
  • Smtp
  • Webdav
  • XmlRpc
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
 1: <?php
 2: 
 3: /**
 4:  * Jyxo PHP Library
 5:  *
 6:  * LICENSE
 7:  *
 8:  * This source file is subject to the new BSD license that is bundled
 9:  * with this package in the file license.txt.
10:  * It is also available through the world-wide-web at this URL:
11:  * https://github.com/jyxo/php/blob/master/license.txt
12:  */
13: 
14: namespace Jyxo\Beholder\TestCase;
15: 
16: /**
17:  * Filesystem access test.
18:  *
19:  * @category Jyxo
20:  * @package Jyxo\Beholder
21:  * @copyright Copyright (c) 2005-2011 Jyxo, s.r.o.
22:  * @license https://github.com/jyxo/php/blob/master/license.txt
23:  * @author Jaroslav HanslĂ­k
24:  */
25: class FileSystem extends \Jyxo\Beholder\TestCase
26: {
27:     /**
28:      * Tested directory.
29:      *
30:      * @var string
31:      */
32:     private $dir;
33: 
34:     /**
35:      * Constructor.
36:      *
37:      * @param string $description Test description
38:      * @param string $dir Tested directory
39:      */
40:     public function __construct($description, $dir)
41:     {
42:         parent::__construct($description);
43: 
44:         $this->dir = (string) $dir;
45:     }
46: 
47:     /**
48:      * Performs the test.
49:      *
50:      * @return \Jyxo\Beholder\Result
51:      */
52:     public function run()
53:     {
54:         $random = md5(uniqid(time(), true));
55:         $path = $this->dir . '/beholder-' . $random . '.txt';
56:         $content = $random;
57: 
58:         // Writing
59:         if (!file_put_contents($path, $content)) {
60:             return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::FAILURE, sprintf('Write error %s', $this->dir));
61:         }
62: 
63:         // Reading
64:         $readContent = file_get_contents($path);
65:         if (strlen($readContent) !== strlen($content)) {
66:             return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::FAILURE, sprintf('Read error %s', $this->dir));
67:         }
68: 
69:         // Deleting
70:         if (!@unlink($path)) {
71:             return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::FAILURE, sprintf('Delete error %s', $this->dir));
72:         }
73: 
74:         // OK
75:         return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::SUCCESS, $this->dir);
76:     }
77: }
78: 
Jyxo PHP Library API documentation generated by ApiGen 2.3.0