Example #1
0
 protected function matches($actual)
 {
     $expected = $this->expected;
     switch (true) {
         case $this->analyzer->isArray($actual):
             $asserter = new asserters\phpArray(null, $this->analyzer);
             $asserter->setWith($actual);
             break;
         case $actual instanceof \iterator:
             $asserter = new asserters\iterator(null, $this->analyzer);
             $asserter = $asserter->setWith($actual)->toArray;
             break;
         case $this->analyzer->isString($actual):
             $asserter = new asserters\phpString(null, $this->analyzer);
             if ($this->ignoreCase) {
                 $actual = strtolower($actual);
                 $expected = strtolower($expected);
             }
             $asserter->setWith($actual);
             break;
         default:
             throw new \PHPUnit_Framework_Exception('Actual value of ' . __CLASS__ . ' must be an array, a string or a traversable object');
     }
     try {
         if ($this->analyzer->isObject($expected)) {
             if ($this->checkForObjectIdentity) {
                 $asserter->strictlyContains($expected);
             } else {
                 $asserter->contains($expected);
             }
         } else {
             if ($this->checkForNonObjectIdentity) {
                 $asserter->strictlyContains($expected);
             } else {
                 $asserter->contains($expected);
             }
         }
     } catch (exception $exception) {
         throw new exception($asserter, $this->analyzer->getTypeOf($actual) . ' does not contain ' . $this->analyzer->getTypeOf($expected));
     }
 }