Overview

Namespaces

  • None
  • Peridot
    • Leo
      • Formatter
      • Interfaces
        • Assert
      • Matcher
        • Template
      • ObjectPath
      • Responder
  • PHP

Traits

  • CollectionAssertTrait
  • ObjectAssertTrait
  • TypeAssertTrait
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: namespace Peridot\Leo\Interfaces\Assert;
  3: 
  4: /**
  5:  * ObjectAssertTrait contains assertions that deal
  6:  * primarily with objects.
  7:  *
  8:  * @package Peridot\Leo\Interfaces\Assert
  9:  */
 10: trait ObjectAssertTrait
 11: {
 12:     /**
 13:      * Perform an instanceof assertion.
 14:      *
 15:      * @param object $object
 16:      * @param string $class
 17:      * @param string $message
 18:      */
 19:     public function isInstanceOf($object, $class, $message = "")
 20:     {
 21:         $this->assertion->setActual($object);
 22:         return $this->assertion->is->instanceof($class, $message);
 23:     }
 24: 
 25:     /**
 26:      * Perform a negated instanceof assertion.
 27:      *
 28:      * @param object $object
 29:      * @param string $class
 30:      * @param string $message
 31:      */
 32:     public function notInstanceOf($object, $class, $message = "")
 33:     {
 34:         $this->assertion->setActual($object);
 35:         return $this->assertion->is->not->instanceof($class, $message);
 36:     }
 37: 
 38:     /**
 39:      * Perform a property assertion.
 40:      *
 41:      * @param array|object $actual
 42:      * @param string $property
 43:      * @param string $message
 44:      */
 45:     public function property($object, $property, $message = "")
 46:     {
 47:         $this->assertion->setActual($object);
 48:         return $this->assertion->to->have->property($property, null, $message);
 49:     }
 50: 
 51:     /**
 52:      * Perform a negated property assertion.
 53:      *
 54:      * @param array|object $actual
 55:      * @param string $property
 56:      * @param string $message
 57:      */
 58:     public function notProperty($object, $property, $message = "")
 59:     {
 60:         $this->assertion->setActual($object);
 61:         return $this->assertion->to->not->have->property($property, null, $message);
 62:     }
 63: 
 64:     /**
 65:      * Perform a deep property assertion.
 66:      *
 67:      * @param array|object $object
 68:      * @param string $property
 69:      * @param string $message
 70:      */
 71:     public function deepProperty($object, $property, $message = "")
 72:     {
 73:         $this->assertion->setActual($object);
 74:         return $this->assertion->to->have->deep->property($property, null, $message);
 75:     }
 76: 
 77:     /**
 78:      * Perform a negated deep property assertion.
 79:      *
 80:      * @param array|object $actual
 81:      * @param string $property
 82:      * @param string $message
 83:      */
 84:     public function notDeepProperty($object, $property, $message = "")
 85:     {
 86:         $this->assertion->setActual($object);
 87:         return $this->assertion->to->not->have->deep->property($property, null, $message);
 88:     }
 89: 
 90:     /**
 91:      * Perform a property value assertion.
 92:      *
 93:      * @param array|object $object
 94:      * @param string $property
 95:      * @param mixed $value
 96:      * @param string $message
 97:      */
 98:     public function propertyVal($object, $property, $value, $message = "")
 99:     {
100:         $this->assertion->setActual($object);
101:         return $this->assertion->to->have->property($property, $value, $message);
102:     }
103: 
104:     /**
105:      * Perform a negated property value assertion.
106:      *
107:      * @param array|object $object
108:      * @param string $property
109:      * @param mixed $value
110:      * @param string $message
111:      */
112:     public function propertyNotVal($object, $property, $value, $message = "")
113:     {
114:         $this->assertion->setActual($object);
115:         return $this->assertion->to->not->have->property($property, $value, $message);
116:     }
117: 
118:     /**
119:      * Perform a deep property value assertion.
120:      *
121:      * @param array|object $object
122:      * @param string $property
123:      * @param mixed $value
124:      * @param string $message
125:      */
126:     public function deepPropertyVal($object, $property, $value, $message = "")
127:     {
128:         $this->assertion->setActual($object);
129:         return $this->assertion->to->have->deep->property($property, $value, $message);
130:     }
131: 
132:     /**
133:      * Perform a negated deep property value assertion.
134:      *
135:      * @param array|object $object
136:      * @param string $property
137:      * @param mixed $value
138:      * @param string $message
139:      */
140:     public function deepPropertyNotVal($object, $property, $value, $message = "")
141:     {
142:         $this->assertion->setActual($object);
143:         return $this->assertion->to->not->have->deep->property($property, $value, $message);
144:     }
145: }
146: 
Leo API documentation generated by ApiGen