Changeset 145
- Timestamp:
- 02/06/07 18:41:05 (2 years ago)
- Files:
-
- trunk/test/build.xml (added)
- trunk/test/classes/phing/BuildFileTest.php (modified) (7 diffs)
- trunk/test/classes/phing/tasks/TypedefTaskTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/test/classes/phing/BuildFileTest.php
r144 r145 39 39 protected $project; 40 40 41 public $logBuffer; 42 public $fullLogBuffer; 41 /** 42 * @var array Array of log BuildEvent objects. 43 */ 44 public $logBuffer = array(); 43 45 44 46 private $outBuffer; … … 46 48 private $buildException; 47 49 50 /** 51 * Asserts that the log buffer contains specified message at specified priority. 52 * @param string $$expected Message subsctring 53 * @param int $priority Message priority (default: any) 54 * @param string $errmsg The error message to display. 55 */ 56 protected function assertInLogs($expected, $priority = null, $errormsg = "Expected to find '%s' in logs: %s") 57 { 58 foreach($this->logBuffer as $log) { 59 if (false !== stripos($log, $expected)) { 60 return; 61 } 62 } 63 $this->fail(sprintf($errormsg, $expected, var_export($this->logBuffer,true))); 64 } 48 65 49 66 /** … … 63 80 protected function expectLog($target, $log) { 64 81 $this->executeTarget($target); 65 $realLog = $this->getLog(); 66 $this->assertEquals($log, $realLog); 82 $this->assertInLogs($log); 67 83 } 68 84 … … 73 89 protected function expectLogContaining($target, $log) { 74 90 $this->executeTarget($target); 75 $realLog = $this->getLog(); 76 $this->assertTrue(strpos($realLog, $log) !== false, "expecting log to contain \"" . $log . "\" log was \"" 77 . $realLog . "\""); 78 } 79 80 /** 81 * Gets the log the BuildFileTest object. 82 * only valid if configureProject() has 83 * been called. 84 * @pre logBuffer!=null 85 * @return The log value 86 */ 87 protected function getLog() { 88 return $this->logBuffer; 91 $this->assertInLogs($log); 89 92 } 90 93 … … 95 98 protected function expectDebuglog($target, $log) { 96 99 $this->executeTarget($target); 97 $realLog = $this->getFullLog(); 98 $this->assertEquals($log, $realLog); 99 } 100 101 /** 102 * Gets the log the BuildFileTest object. 103 * only valid if configureProject() has 104 * been called. 105 * @pre fullLogBuffer!=null 106 * @return The log value 107 */ 108 protected function getFullLog() { 109 return $this->fullLogBuffer; 100 $this->assertInLogs($log, Project::MSG_DEBUG); 110 101 } 111 102 … … 344 335 private $parent; 345 336 346 function __construct($parent) {347 $this->parent = $parent;337 public function __construct($parent) { 338 $this->parent = $parent; 348 339 } 349 340 … … 408 399 */ 409 400 public function messageLogged(BuildEvent $event) { 410 if ($event->getPriority() == Project::MSG_INFO || 411 $event->getPriority() == Project::MSG_WARN || 412 $event->getPriority() == Project::MSG_ERR) { 413 $this->parent->logBuffer .= $event->getMessage(); 414 } 415 $this->parent->fullLogBuffer .= $event->getMessage(); 401 $this->parent->logBuffer[] = $event->getMessage(); 416 402 } 417 403 } trunk/test/classes/phing/tasks/TypedefTaskTest.php
r123 r145 50 50 51 51 public function testGlobal() { 52 $this->expectLog("testGlobal", " ");52 $this->expectLog("testGlobal", "Adding reference: global -> TypedefTestType"); 53 53 $refs = $this->project->getReferences(); 54 54 $ref = $refs["global"]; … … 58 58 59 59 public function testLocal() { 60 $this->expectLog("testLocal", " ");60 $this->expectLog("testLocal", "Adding reference: local -> TypedefTestType"); 61 61 $refs = $this->project->getReferences(); 62 62 $ref = $refs["local"];
