public function testSettersAndGetters() { $provider = new Provider(); Property::set($provider, 'id', 105); $provider->setName('Twitter'); $this->assertEquals(105, $provider->getId()); $this->assertEquals('Twitter', $provider->getName()); }
/** * Make sure that we can unregister a subject. */ public function testOffsetUnset() { $subject = new Subject(); Property::set($this->collection, 'subjects', array('test' => $subject)); unset($this->collection['test']); unset($this->collection['test']); // should not thrown an exception $this->assertSame(array(), Property::get($this->collection, 'subjects'), 'Make sure the "test" subject is unregistered.'); }
protected function expect404(ImageController $controller) { $event = new MvcEvent(); $controller->setEvent($event); $routeMatch = $this->getMockBuilder('Zend\\Mvc\\Router\\RouteMatch')->disableOriginalConstructor()->getMock(); $event->setRouteMatch($routeMatch); $response = $this->getMock('Zend\\Http\\Response'); $response->expects($this->once())->method('setStatusCode')->with(404); Property::set($controller, 'response', $response); }
/** * {@inheritDoc} */ public function receiveUpdate(SubjectInterface $subject) { $this->order = self::$counter++; $this->subject = $subject; if ($this->double) { $subject->notifyObservers(); } if ($this->test) { $this->test->assertTrue(Property::get($subject, 'updating'), 'The subject should be updating.'); } if ($this->interrupt) { $this->reason = new ReasonException('Testing interruption.'); $subject->interruptUpdate($this->reason); } }
/** * Make sure that we can unregister a single occurrences of an observer. */ public function testUnregisterObserver() { $observers = array(new Observer(), new Observer(), new Observer()); Property::set($this->subject, 'observers', array(456 => array($observers[2], $observers[2]), 0 => array($observers[0], $observers[1]), 123 => array($observers[0], $observers[1], $observers[2], $observers[1]))); $this->subject->unregisterObserver($observers[0]); $this->assertSame(array(0 => array(1 => $observers[1]), 123 => array($observers[0], $observers[1], $observers[2], $observers[1]), 456 => array($observers[2], $observers[2])), Property::get($this->subject, 'observers'), 'Unregister the first occurrence sorted by priority.'); $this->subject->unregisterObserver($observers[2], 456); $this->assertSame(array(0 => array(1 => $observers[1]), 123 => array($observers[0], $observers[1], $observers[2], $observers[1]), 456 => array(1 => $observers[2])), Property::get($this->subject, 'observers'), 'Unregister the first occurrence for a specific priority.'); }
/** * Make sure that we can unregister a subject. */ public function testUnregisterSubject() { Property::set($this->collection, 'subjects', array('test' => new Subject())); $this->collection->unregisterSubject('test'); $this->assertSame(array(), Property::get($this->collection, 'subjects'), 'Make sure the "test" subject is unregistered.'); }