SitePoint Sponsor

User Tag List

Page 3 of 3 FirstFirst 123
Results 51 to 52 of 52
  1. #51
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lastcraft View Post
    See the CanUseDifferentDependencySetWithinAnInterface test case.
    It could be that there is more than one instance of the same class and each instance needs to fill the dependency differently:

    PHP Code:
    abstract class Scientist {

        function 
    __construct(Publisher $publisher) {
            
    $this->publisher $publisher;
        }
        function 
    getPublisher() {
            return 
    get_class($publisher);
        }
    }
    class 
    Dawkins extends Scientist {}
    class 
    Hawking extends Scientist {}

    interface 
    Publisher {}
    class 
    AmericanPublisher implements Publisher {}
    class 
    BritishPublisher implements Publisher {}

    class 
    CanUseDifferentDependencySetWithinAnInterface extends UnitTestCase {

        function 
    testCanSetDifferentPreferencesForInstancesOfTheSameClass() {
            
    $globe = new Phemto();
            
    $britain $globe->getSubgraph();
            
    $america $globe->getSubgraph();

            
    $globe->register('Dawkins');
            
    $america->register('AmericanPublisher');
            
    $britain->register('BritishPublisher');
            
            
    $scientist $britain->instantiate('Scientist');
            
    $this->assertEqual(
                
    $scientist->getPublisher(), 
                
    'BritishPublisher');

            
    $scientist $america->instantiate('Scientist');
            
    $this->assertEqual(
                
    $scientist->getPublisher(), 
                
    'AmericanPublisher');
        } 

  2. #52
    ********* Victim lastcraft's Avatar
    Join Date
    Apr 2003
    Location
    London
    Posts
    2,423
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi...

    I've started a new thread here with a leter version of Phemto...
    http://www.sitepoint.com/forums/showthread.php?t=587455.

    yours, Marcus
    Marcus Baker
    Testing: SimpleTest, Cgreen, Fakemail
    Other: Phemto dependency injector
    Books: PHP in Action, 97 things


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •