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>
|
||||
*/
|
||||
class CustomFieldTestHelper
|
||||
trait CustomFieldTestHelper
|
||||
{
|
||||
|
||||
/**
|
||||
* Prepare a crawler containing the rendering of a customField
|
||||
*
|
||||
@ -44,18 +45,20 @@ class CustomFieldTestHelper
|
||||
* @param type $locale
|
||||
* @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
|
||||
$customFieldsGroup = $testCase->getMock('Chill\CustomFieldsBundle\Entity\CustomFieldsGroup');
|
||||
$customFieldsGroup->expects($testCase->once())
|
||||
->method('getActiveCustomFields')
|
||||
->will($testCase->returnValue(array($field)));
|
||||
$kernel = static::$kernel;
|
||||
|
||||
$request = $testCase->getMock('Symfony\Component\HttpFoundation\Request');
|
||||
$request->expects($testCase->any())
|
||||
//check a kernel is accessible
|
||||
$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')
|
||||
->will($testCase->returnValue($locale));
|
||||
->will($this->returnValue($locale));
|
||||
|
||||
$kernel->getContainer()->get('request_stack')->push($request);
|
||||
|
||||
@ -79,4 +82,4 @@ class CustomFieldTestHelper
|
||||
|
||||
return $crawler;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,8 @@ class CustomFieldsTextTest extends WebTestCase
|
||||
*/
|
||||
private $customFieldProvider;
|
||||
|
||||
use CustomFieldTestHelper;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
static::bootKernel();
|
||||
@ -67,7 +69,7 @@ class CustomFieldsTextTest extends WebTestCase
|
||||
->setActive(true)
|
||||
->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("label:contains('my label')"));
|
||||
@ -83,7 +85,7 @@ class CustomFieldsTextTest extends WebTestCase
|
||||
->setActive(true)
|
||||
->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("label:contains('my label')"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user