Created
February 11, 2014 22:01
-
-
Save mustafaileri/8945118 to your computer and use it in GitHub Desktop.
Sample test with mock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* User: Mustafa Ileri | |
* Date: 7/28/13 | |
* Time: 11:29 PM | |
* Please type something... | |
*/ | |
namespace Hezarfen\Bundle\CmsBundle\Tests\Service; | |
use Hezarfen\Bundle\CmsBundle\Service\CmsService; | |
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | |
class CmsServiceTest extends WebTestCase | |
{ | |
public function testGetAll() | |
{ | |
$client = static::createClient(); | |
$modelMock = $this->getMockBuilder('Hezarfen\Bundle\CmsBundle\Model\CmsModel') | |
->setMethods(array('getAll'))->disableOriginalConstructor()->getMock(); | |
$modelMock->expects($this->any())->method('getAll')->will($this->returnValue(array())); | |
$client->getContainer()->set('hezarfen_cms.model', $modelMock); | |
/** @var CmsService $cmsService */ | |
$cmsService = $client->getContainer()->get('hezarfen_cms.service'); | |
$this->assertTrue(is_array($cmsService->getAll())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment