Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

Implemented test suite for widget rendering #275

Merged
merged 1 commit into from
Aug 16, 2016

Conversation

core23
Copy link
Member

@core23 core23 commented May 28, 2016

Changelog

### Added
- Added `AbstractWidgetTestCase` test suite

Subject

Added a test suite for widget rendering. Basically it's a port of https://github.com/sonata-project/SonataAdminBundle/blob/3.x/Tests/Form/Widget/BaseWidgetTest.php to have a test suite for all bundles.

This can be used for sonata-project/SonataFormatterBundle#146


/**
* Class BaseWidgetTest.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@author tag is missing

@OskarStark
Copy link
Member

LGTM 👍

@greg0ire can you give us a final review please?

/**
* {@inheritdoc}
*/
public function setUp()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be protected

@core23 core23 force-pushed the widget-test branch 4 times, most recently from a141da5 to 2285fed Compare May 30, 2016 15:54
*
* @author Christian Gripp <mail@core23.de>
*/
abstract class BaseWidgetTest extends TypeTestCase
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@soullivaneuh
Copy link
Member

Please wait sonata-project/dev-kit#116 (comment) decision before merge.

@OskarStark
Copy link
Member

@core23 we have a decision, can you please check if this PR fullfill this?

@core23
Copy link
Member Author

core23 commented Jun 15, 2016

Don't know what's missing.

__DIR__.'/../../../vendor/symfony/twig-bridge/Symfony/Bridge/Twig/Resources/views/Form',
__DIR__.'/../../../vendor/symfony/twig-bridge/Resources/views/Form',
__DIR__.'/../../../vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form',
__DIR__.'/../../../../../symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document each line, explaining in which situation each can happen. If you don't know, simply remove the line, and it will be added later with a comment if really needed. BTW, I don't think running tests from a Symfony project should be supported.

@soullivaneuh
Copy link
Member

A test case should have documentation of how to use it.

@soullivaneuh
Copy link
Member

BTW, a test that meant to be publicly used should be tested as well. Or at lest implemented on this bundle for code coverage.

@greg0ire
Copy link
Contributor

BTW, a test that meant to be publicly used should be tested as well. Or at lest implemented on this bundle for code coverage.

Testception :)

@core23 core23 force-pushed the widget-test branch 2 times, most recently from 1608b2e to 3fb5734 Compare June 17, 2016 13:52
@core23
Copy link
Member Author

core23 commented Jul 3, 2016

Added NEXT_MAJOR notes for symfony BC hacks. Hope everything is fine now 👍

@core23
Copy link
Member Author

core23 commented Jul 14, 2016

Added a new Test chapter to the documentation.

@core23
Copy link
Member Author

core23 commented Jul 21, 2016

RTM?

@core23 core23 force-pushed the widget-test branch 4 times, most recently from 2f71a2c to ff3b770 Compare July 28, 2016 17:00
@core23
Copy link
Member Author

core23 commented Jul 28, 2016

Ping @soullivaneuh @greg0ire

@core23
Copy link
Member Author

core23 commented Aug 9, 2016

Can you give a final review @soullivaneuh @greg0ire

$html = $this->renderWidget($choice->createView());

$this->assertContains(
'<div id="choice"><input type="checkbox" id="choice_0" name="choice[]" value="0" /><label for="choice_0">[trans]some[/trans]</label><input type="checkbox" id="choice_1" name="choice[]" value="1" /><label for="choice_1">[trans]choices[/trans]</label></div>',
Copy link
Contributor

@greg0ire greg0ire Aug 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use line breaks here please :

<?php
$this->cleanHtmlWhitespace(<<<HTML
<div id="choice">
    <input type="checkbox" id="choice_0" name="choice[]" value="0" />
    <label for="choice_0">[trans]some[/trans]</label>
    <input type="checkbox" id="choice_1" name="choice[]" value="1" />
    <label for="choice_1">[trans]choices[/trans]</label>
</div>
HTML)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed that

@OskarStark
Copy link
Member

@core23 can you please check travis?

@core23
Copy link
Member Author

core23 commented Aug 15, 2016

All green :)

@greg0ire
Copy link
Contributor

LGTM

@OskarStark OskarStark merged commit 5224529 into sonata-project:3.x Aug 16, 2016
@OskarStark
Copy link
Member

Thank you @core23 👍

@core23 core23 deleted the widget-test branch August 16, 2016 08:17
@core23 core23 mentioned this pull request Aug 17, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants