public function testShow() { $articleData = $this->_getArticleData(); $testArticle = new Article($articleData['title'], $articleData['body']); $articleId = 15; $this->_mockEntityManagerFacade(); EntityManager::shouldReceive('find')->with(Article::class, $articleId)->andReturn($testArticle); $this->visit('/articles/' . $articleId)->see($articleData['title'])->see($articleData['body']); }
protected function _mockEntityManagerFacade() { // Now, mock the repository so it returns the mock of the employee /** @var TestCase $this */ $testRepository = $this->getMockBuilder(ArticleRepository::class)->disableOriginalConstructor()->getMock(); // Last, mock the EntityManager to return the mock of the repository EntityManager::shouldReceive('getRepository')->with(Article::class)->andReturn($testRepository); /** @var DatabaseTransactions $this */ EntityManager::shouldReceive('getConnection')->andReturn($this->_getMockConnection()); }