One such instance is when it's discussing mock objects (I know, PHPUnit's mock object support isn't as good as SimpleTest's, but my company switched from SimpleTest to PHPUnit for some reason, so I need to learn to cope)...I guess my main question is where and how do I get access to the $subject->attach() method that it examples? This is from here: http://www.phpunit.de/pocket_guide/3.2/ ... jects.html, and the excerpt:
Code: Select all
<?php
require_once 'PHPUnit/Framework.php';
class ObserverTest extends PHPUnit_Framework_TestCase
{
public function testUpdateIsCalledOnce()
{
// Create a Mock Object for the Observer class
// mocking only the update() method.
$observer = $this->getMock('Observer', array('update'));
// Set up the expectation for the update() method
// to be called only once and with the string 'something'
// as its parameter.
$observer->expects($this->once())
->method('update')
->with($this->equalTo('something'));
// Create a Subject object and attach the mocked
// Observer object to it.
$subject = new Subject;
$subject->attach($observer);
// Call the doSomething() method on the $subject object
// which we expect to call the mocked Observer object's
// update() method with the string 'something'.
$subject->doSomething();
}
}
?>
Code: Select all
$subject = new Subject;
$subject->attach($observer);
Does anyone know how I can attach the two? Or rather, what $subject is, and where the attach() method comes from?
Also, I really hope you guys get that PHPMock framework up and running, it looks awesome and I will definately use it over this weird PHPUnit mock implementation.