/** * @covers Housekeeper\Eloquent\BaseRepository::sortInjection */ public function testSortInjection() { $mockRepository = $this->makeMockRepository(); /** * Mock three injections to test sorting, equal, lesser and greater. */ $mockInjection_1 = m::mock('Housekeeper\\Contracts\\Injection\\InjectionInterface'); $mockInjection_1->shouldReceive('priority')->andReturn('1'); $mockInjection_2 = m::mock('Housekeeper\\Contracts\\Injection\\InjectionInterface'); $mockInjection_2->shouldReceive('priority')->andReturn('2'); $mockInjection_3 = m::mock('Housekeeper\\Contracts\\Injection\\InjectionInterface'); $mockInjection_3->shouldReceive('priority')->andReturn('1'); /** * Get the "sort" method. */ $methodSortInjection = getUnaccessibleObjectMethod($mockRepository, 'sortInjection'); $this->assertEquals(-1, $methodSortInjection->invoke($mockRepository, $mockInjection_1, $mockInjection_2)); $this->assertEquals(1, $methodSortInjection->invoke($mockRepository, $mockInjection_2, $mockInjection_1)); $this->assertEquals(0, $methodSortInjection->invoke($mockRepository, $mockInjection_1, $mockInjection_1)); }
/** * @covers Housekeeper\Repository::getModel */ public function testGetModel() { $mockPlan = m::mock(); $mockPlan->shouldReceive('getModel')->andReturn(''); $mockRepository = $this->makeMockRepository(MockSetupRepository::class, false); $mockRepository->shouldReceive('getCurrentPlan')->andReturn($mockPlan); $methodGetModel = getUnaccessibleObjectMethod($mockRepository, 'getModel'); $methodGetModel->invoke($mockRepository); $mockPlan->shouldHaveReceived('getModel')->once(); }