Development

Changeset 20971

You must first sign up to be able to contribute.

Changeset 20971

Show
Ignore:
Timestamp:
08/09/09 19:54:27 (5 years ago)
Author:
bschussek
Message:

Improved string representation of mocked methods

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/lime/branches/2.0-experimental/lib/LimePrinter.php

    r20970 r20971  
    108108      if ($text{0} == '"') 
    109109      { 
    110         return $this->colorizer->colorize(trim($text, '"'), self::STRING); 
     110        return $this->colorizer->colorize($text, self::STRING); 
    111111      } 
    112112      else 
  • tools/lime/branches/2.0-experimental/lib/mock/LimeMockInvocation.php

    r20958 r20971  
    111111  public function __toString() 
    112112  { 
    113     return sprintf('%s::%s(%s)', $this->class, $this->method, implode(', ', (array)$this->parameters)); 
     113    $parameters = $this->parameters; 
     114 
     115    if (is_array($parameters)) 
     116    { 
     117      foreach ($parameters as $key => $value) 
     118      { 
     119        if (is_string($value)) 
     120        { 
     121          $value = str_replace(array("\n", "\t", "\r"), array('\n', '\t', '\r'), $value); 
     122          $value = strlen($value) > 30 ? substr($value, 0, 30).'...' : $value; 
     123          $parameters[$key] = '"'.$value.'"'; 
     124        } 
     125        else if (is_object($value)) 
     126        { 
     127          $parameters[$key] = get_class($value); 
     128        } 
     129        else if (is_array($value)) 
     130        { 
     131          $parameters[$key] = 'array'; 
     132        } 
     133        else 
     134        { 
     135          $parameters[$key] = var_export($value, true); 
     136        } 
     137      } 
     138    } 
     139 
     140    return sprintf('%s(%s)', $this->method, implode(', ', (array)$parameters)); 
    114141  } 
    115142} 
  • tools/lime/branches/2.0-experimental/lib/mock/matcher/LimeMockInvocationMatcherParameters.php

    r20293 r20971  
    3939  public function getMessage() 
    4040  { 
    41     return 'The method '.$this->invocation.' was called'; 
     41    return $this->invocation.' was called'; 
    4242  } 
    4343} 
  • tools/lime/branches/2.0-experimental/test/unit/LimePrinterTest.php

    r20970 r20971  
    9999 
    100100  // fixtures 
    101   $colorizer->colorize('Test string', LimePrinter::STRING)->returns('<BLUE>Test string</BLUE>'); 
     101  $colorizer->colorize('"Test string"', LimePrinter::STRING)->returns('<BLUE>"Test string"</BLUE>'); 
    102102  $colorizer->replay(); 
    103103  // test 
     
    106106  $result = ob_get_clean(); 
    107107  // assertions 
    108   $t->is($result, 'My text with a <BLUE>Test string</BLUE>', 'The result was colorized and printed'); 
     108  $t->is($result, 'My text with a <BLUE>"Test string"</BLUE>', 'The result was colorized and printed'); 
    109109 
    110110/*