1: <?php
2:
3: /**
4: * Base class for all QCubed unit tests. Contains shared functionality.
5: * @package Tests
6: */
7:
8: class QUnitTestCaseBase extends \PHPUnit_Framework_TestCase {
9:
10: /**
11: * Given an array of objects $arrObj, verifies that
12: * there is an object inside with a property $strPropertyName
13: * that equals $mixExpectedValue.
14: *
15: * @param $arrObj Array of objects to look through
16: * @param $strPropertyName Name of the property to validate each item on
17: * @param $mixExpectedValue Value of the property to look for
18: *
19: * @return $mixObject The object in the array that had the property value we were looking for
20: */
21: protected function verifyObjectPropertyHelper($arrObj, $strPropertyName, $mixExpectedValue) {
22: $objResult = null;
23: $className = "object";
24: if (sizeof($arrObj) > 0) {
25: foreach ($arrObj as $objItem) {
26: if ($objItem->$strPropertyName == $mixExpectedValue) {
27: $objResult = $objItem;
28: break;
29: }
30: }
31: $className = get_class($arrObj[0]);
32: }
33:
34: $this->assertNotNull($objResult, "Found a " . $className . " with " . $strPropertyName . " = " . $mixExpectedValue);
35: return $objResult;
36: }
37: }
38: