-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/dev/1.10' into 1.10
- Loading branch information
Showing
50 changed files
with
1,861 additions
and
512 deletions.
There are no files selected for viewing
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
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
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
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
86 changes: 86 additions & 0 deletions
86
src/Oro/Bundle/DashboardBundle/Tests/Functional/AbstractWidgetTestCase.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
namespace Oro\Bundle\DashboardBundle\Tests\Functional; | ||
|
||
use Symfony\Component\DomCrawler\Crawler; | ||
use Symfony\Component\DomCrawler\Field\InputFormField; | ||
use Symfony\Component\DomCrawler\Form; | ||
|
||
use Oro\Bundle\TestFrameworkBundle\Test\WebTestCase; | ||
use Oro\Bundle\DashboardBundle\Entity\Widget; | ||
|
||
class AbstractWidgetTestCase extends WebTestCase | ||
{ | ||
/** | ||
* @param Form $form | ||
* @param string $fieldName | ||
* @param mixed $value | ||
* @param string $fieldType | ||
*/ | ||
protected function setOrAdd(Form $form, $fieldName, $value, $fieldType = 'text') | ||
{ | ||
if (!$form->has($fieldName)) { | ||
$doc = new \DOMDocument("1.0"); | ||
$doc->loadHTML(sprintf('<input type="%s" name="%s" value="" />', $fieldType, $fieldName)); | ||
$dynamicField = new InputFormField($doc->getElementsByTagName('input')->item(0)); | ||
$form->set($dynamicField); | ||
} | ||
|
||
$form[$fieldName] = $value; | ||
} | ||
|
||
/** | ||
* @param Widget $widget | ||
* @param array $configFields | ||
*/ | ||
protected function configureWidget(Widget $widget, array $configFields) | ||
{ | ||
$this->client->request( | ||
'GET', | ||
$this->getUrl( | ||
'oro_dashboard_configure', | ||
['id' => $widget->getId(), '_widgetContainer' => 'dialog'] | ||
) | ||
); | ||
$response = $this->client->getResponse(); | ||
$this->assertEquals($response->getStatusCode(), 200, 'Failed in getting configure widget dialog window !'); | ||
|
||
/** | ||
* @var $crawler Crawler | ||
* @var $form Form | ||
*/ | ||
$crawler = $this->client->getCrawler(); | ||
/** @var Form $form */ | ||
$form = $crawler->selectButton('Save')->form(); | ||
|
||
foreach ($configFields as $fieldsName => $value) { | ||
$this->setOrAdd($form, $fieldsName, $value); | ||
} | ||
|
||
$this->client->submit($form); | ||
|
||
$response = $this->client->getResponse(); | ||
$this->assertEquals($response->getStatusCode(), 200, "Failed in submit widget configuration options !"); | ||
} | ||
|
||
/** | ||
* Returns data for which will be used to show widget's chart | ||
* | ||
* @param $crawler | ||
* @return array | ||
*/ | ||
protected function getChartData($crawler) | ||
{ | ||
$dataComponent = $crawler->filter('.column-chart'); | ||
if ($dataComponent->extract(['data-page-component-options'])) { | ||
$data = $dataComponent->extract(['data-page-component-options']); | ||
$data = json_decode($data[0]); | ||
return $data->chartOptions->dataSource->data; | ||
} else { | ||
$dataComponent = $crawler->filter('.dashboard-widget-content > [data-page-component-options]'); | ||
$data = $dataComponent->extract(['data-page-component-options']); | ||
$data = json_decode($data[0]); | ||
return $data->data; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.