mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-14 14:24:24 +00:00
fixing error in creating mock
A public method became protected in phpunit
This commit is contained in:
parent
0899a931e4
commit
c58d101ade
@ -30,8 +30,9 @@ use Symfony\Component\DomCrawler\Crawler;
|
|||||||
*
|
*
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
*/
|
*/
|
||||||
class CustomFieldTestHelper
|
trait CustomFieldTestHelper
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare a crawler containing the rendering of a customField
|
* Prepare a crawler containing the rendering of a customField
|
||||||
*
|
*
|
||||||
@ -44,18 +45,20 @@ class CustomFieldTestHelper
|
|||||||
* @param type $locale
|
* @param type $locale
|
||||||
* @return Crawler
|
* @return Crawler
|
||||||
*/
|
*/
|
||||||
public static function getCrawlerForField(CustomField $field, KernelTestCase $testCase, KernelInterface $kernel, $locale = 'en')
|
public function getCrawlerForField(CustomField $field, $locale = 'en')
|
||||||
{
|
{
|
||||||
//check a kernel is accessible
|
$kernel = static::$kernel;
|
||||||
$customFieldsGroup = $testCase->getMock('Chill\CustomFieldsBundle\Entity\CustomFieldsGroup');
|
|
||||||
$customFieldsGroup->expects($testCase->once())
|
|
||||||
->method('getActiveCustomFields')
|
|
||||||
->will($testCase->returnValue(array($field)));
|
|
||||||
|
|
||||||
$request = $testCase->getMock('Symfony\Component\HttpFoundation\Request');
|
//check a kernel is accessible
|
||||||
$request->expects($testCase->any())
|
$customFieldsGroup = $this->createMock('Chill\CustomFieldsBundle\Entity\CustomFieldsGroup');
|
||||||
|
$customFieldsGroup->expects($this->once())
|
||||||
|
->method('getActiveCustomFields')
|
||||||
|
->will($this->returnValue(array($field)));
|
||||||
|
|
||||||
|
$request = $this->createMock('Symfony\Component\HttpFoundation\Request');
|
||||||
|
$request->expects($this->any())
|
||||||
->method('getLocale')
|
->method('getLocale')
|
||||||
->will($testCase->returnValue($locale));
|
->will($this->returnValue($locale));
|
||||||
|
|
||||||
$kernel->getContainer()->get('request_stack')->push($request);
|
$kernel->getContainer()->get('request_stack')->push($request);
|
||||||
|
|
||||||
@ -79,4 +82,4 @@ class CustomFieldTestHelper
|
|||||||
|
|
||||||
return $crawler;
|
return $crawler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,8 @@ class CustomFieldsTextTest extends WebTestCase
|
|||||||
*/
|
*/
|
||||||
private $customFieldProvider;
|
private $customFieldProvider;
|
||||||
|
|
||||||
|
use CustomFieldTestHelper;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
static::bootKernel();
|
static::bootKernel();
|
||||||
@ -67,7 +69,7 @@ class CustomFieldsTextTest extends WebTestCase
|
|||||||
->setActive(true)
|
->setActive(true)
|
||||||
->setName(array('en' => 'my label'));
|
->setName(array('en' => 'my label'));
|
||||||
|
|
||||||
$crawler = CustomFieldTestHelper::getCrawlerForField($customField, $this, static::$kernel);
|
$crawler = $this->getCrawlerForField($customField);
|
||||||
|
|
||||||
$this->assertCount(1, $crawler->filter("input[type=text]"));
|
$this->assertCount(1, $crawler->filter("input[type=text]"));
|
||||||
$this->assertCount(1, $crawler->filter("label:contains('my label')"));
|
$this->assertCount(1, $crawler->filter("label:contains('my label')"));
|
||||||
@ -83,7 +85,7 @@ class CustomFieldsTextTest extends WebTestCase
|
|||||||
->setActive(true)
|
->setActive(true)
|
||||||
->setName(array('en' => 'my label'));
|
->setName(array('en' => 'my label'));
|
||||||
|
|
||||||
$crawler = CustomFieldTestHelper::getCrawlerForField($customField, $this, static::$kernel);
|
$crawler = $this->getCrawlerForField($customField);
|
||||||
|
|
||||||
$this->assertCount(1, $crawler->filter("textarea"));
|
$this->assertCount(1, $crawler->filter("textarea"));
|
||||||
$this->assertCount(1, $crawler->filter("label:contains('my label')"));
|
$this->assertCount(1, $crawler->filter("label:contains('my label')"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user