Add tests
This commit is contained in:
parent
c607990991
commit
567999909f
|
|
@ -26,7 +26,9 @@
|
||||||
"tymon/jwt-auth": "dev-develop",
|
"tymon/jwt-auth": "dev-develop",
|
||||||
"laravel/passport": "^7.3",
|
"laravel/passport": "^7.3",
|
||||||
"composer/ca-bundle": "^1.2",
|
"composer/ca-bundle": "^1.2",
|
||||||
"tormjens/eventy": "^0.5.7"
|
"tormjens/eventy": "^0.5.7",
|
||||||
|
"symfony/dom-crawler": "^4.3",
|
||||||
|
"symfony/css-selector": "^4.3"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"fzaninotto/faker": "~1.8",
|
"fzaninotto/faker": "~1.8",
|
||||||
|
|
|
||||||
124
composer.lock
generated
124
composer.lock
generated
|
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "eb71fb9d875289395e7b43be6a663b41",
|
"content-hash": "81cc569f3b1add879c27bd6f055349ce",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "composer/ca-bundle",
|
"name": "composer/ca-bundle",
|
||||||
|
|
@ -2884,6 +2884,67 @@
|
||||||
"homepage": "https://symfony.com",
|
"homepage": "https://symfony.com",
|
||||||
"time": "2019-07-23T11:21:36+00:00"
|
"time": "2019-07-23T11:21:36+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/dom-crawler",
|
||||||
|
"version": "v4.3.3",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/dom-crawler.git",
|
||||||
|
"reference": "291397232a2eefb3347eaab9170409981eaad0e2"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/291397232a2eefb3347eaab9170409981eaad0e2",
|
||||||
|
"reference": "291397232a2eefb3347eaab9170409981eaad0e2",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.1.3",
|
||||||
|
"symfony/polyfill-ctype": "~1.8",
|
||||||
|
"symfony/polyfill-mbstring": "~1.0"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"masterminds/html5": "<2.6"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"masterminds/html5": "^2.6",
|
||||||
|
"symfony/css-selector": "~3.4|~4.0"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"symfony/css-selector": ""
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "4.3-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Component\\DomCrawler\\": ""
|
||||||
|
},
|
||||||
|
"exclude-from-classmap": [
|
||||||
|
"/Tests/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Fabien Potencier",
|
||||||
|
"email": "fabien@symfony.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Symfony DomCrawler Component",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"time": "2019-06-13T11:03:18+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/event-dispatcher",
|
"name": "symfony/event-dispatcher",
|
||||||
"version": "v4.3.3",
|
"version": "v4.3.3",
|
||||||
|
|
@ -6647,67 +6708,6 @@
|
||||||
"homepage": "https://github.com/sebastianbergmann/version",
|
"homepage": "https://github.com/sebastianbergmann/version",
|
||||||
"time": "2016-10-03T07:35:21+00:00"
|
"time": "2016-10-03T07:35:21+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "symfony/dom-crawler",
|
|
||||||
"version": "v4.3.3",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/symfony/dom-crawler.git",
|
|
||||||
"reference": "291397232a2eefb3347eaab9170409981eaad0e2"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/291397232a2eefb3347eaab9170409981eaad0e2",
|
|
||||||
"reference": "291397232a2eefb3347eaab9170409981eaad0e2",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^7.1.3",
|
|
||||||
"symfony/polyfill-ctype": "~1.8",
|
|
||||||
"symfony/polyfill-mbstring": "~1.0"
|
|
||||||
},
|
|
||||||
"conflict": {
|
|
||||||
"masterminds/html5": "<2.6"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"masterminds/html5": "^2.6",
|
|
||||||
"symfony/css-selector": "~3.4|~4.0"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"symfony/css-selector": ""
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "4.3-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Component\\DomCrawler\\": ""
|
|
||||||
},
|
|
||||||
"exclude-from-classmap": [
|
|
||||||
"/Tests/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Fabien Potencier",
|
|
||||||
"email": "fabien@symfony.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Symfony DomCrawler Component",
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"time": "2019-06-13T11:03:18+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "theseer/tokenizer",
|
"name": "theseer/tokenizer",
|
||||||
"version": "1.1.3",
|
"version": "1.1.3",
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ namespace Tests;
|
||||||
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use App\Services\OptionForm;
|
use App\Services\OptionForm;
|
||||||
|
use Symfony\Component\DomCrawler\Crawler;
|
||||||
|
|
||||||
class OptionFormTest extends TestCase
|
class OptionFormTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
@ -78,9 +79,9 @@ class OptionFormTest extends TestCase
|
||||||
$form = new OptionForm('test', 'test');
|
$form = new OptionForm('test', 'test');
|
||||||
$form->text('text');
|
$form->text('text');
|
||||||
$form->renderInputTagsOnly();
|
$form->renderInputTagsOnly();
|
||||||
$html = $form->render();
|
$crawler = new Crawler($form->render());
|
||||||
$this->assertFalse(Str::contains($html, '<td class="key">'));
|
$this->assertCount(0, $crawler->filter('td.key'));
|
||||||
$this->assertTrue(Str::contains($html, '<td class="value">'));
|
$this->assertCount(1, $crawler->filter('td.value'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRenderWithoutSubmitButton()
|
public function testRenderWithoutSubmitButton()
|
||||||
|
|
@ -88,7 +89,25 @@ class OptionFormTest extends TestCase
|
||||||
$form = new OptionForm('test', 'test');
|
$form = new OptionForm('test', 'test');
|
||||||
$form->text('text');
|
$form->text('text');
|
||||||
$form->renderWithoutSubmitButton();
|
$form->renderWithoutSubmitButton();
|
||||||
$html = $form->render();
|
$crawler = new Crawler($form->render());
|
||||||
$this->assertFalse(Str::contains($html, '<button'));
|
$this->assertCount(0, $crawler->filter('button'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDisallowInvalidType()
|
||||||
|
{
|
||||||
|
$this->expectException(\BadMethodCallException::class);
|
||||||
|
$form = new OptionForm('test', 'test');
|
||||||
|
$form->nope();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAddMessage()
|
||||||
|
{
|
||||||
|
$form = new OptionForm('test', 'test');
|
||||||
|
$form->addMessage();
|
||||||
|
$form->addMessage('greeting', 'warning');
|
||||||
|
|
||||||
|
$crawler = new Crawler($form->render());
|
||||||
|
$this->assertEquals(trans('options.test.message'), $crawler->filter('.callout-info')->text());
|
||||||
|
$this->assertEquals('greeting', $crawler->filter('.callout-warning')->text());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user