コード例 #1
0
 public function test_unidirectionalOneAssociation()
 {
     $other = new ClassOtherclass("otherClass");
     $one = new ClassOne($other);
     $this->assertTrue($one->getClassOtherclass() == $other);
     try {
         $one = new ClassOne(null);
         $this->fail("Constructor should have thrown Exception");
     } catch (Exception $ex) {
     }
     $this->assertFalse($this->objectClassHasSettersAddersOrRemovers($one));
 }
コード例 #2
0
ファイル: ClassOne.php プロジェクト: lucatume/di52
 public static function reset()
 {
     self::$methodOneCalled = 0;
     self::$methodTwoCalled = 0;
     self::$methodThreeCalled = 0;
 }
コード例 #3
0
ファイル: ResolverTest.php プロジェクト: lucatume/di52
 /**
  * @test
  * it should call after builds methods on singleton just once
  */
 public function it_should_call_after_builds_methods_on_singleton_just_once()
 {
     $sut = $this->makeInstance();
     ClassOne::reset();
     $sut->singleton('one', 'ClassOne', array('methodOne', 'methodTwo', 'methodThree'));
     $i1 = $sut->resolve('one');
     $this->assertEquals(1, $i1->getMethodOneCalled());
     $this->assertEquals(1, $i1->getMethodTwoCalled());
     $this->assertEquals(1, $i1->getMethodThreeCalled());
     $i2 = $sut->resolve('one');
     $this->assertSame($i1, $i2);
     $this->assertEquals(1, $i2->getMethodOneCalled());
     $this->assertEquals(1, $i2->getMethodTwoCalled());
     $this->assertEquals(1, $i2->getMethodThreeCalled());
 }