<commit_before><?php
/*
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * This software consists of voluntary contributions made by many individuals
 * and is licensed under the MIT license.
 */

namespace RoaveTest\DeveloperTools\Renderer;

use PHPUnit_Framework_TestCase;
use Roave\DeveloperTools\Inspection\AggregateInspection;
use Roave\DeveloperTools\Inspection\InspectionInterface;
use Roave\DeveloperTools\Inspection\TimeInspection;
use Roave\DeveloperTools\Renderer\BaseInspectionRenderer;
use Roave\DeveloperTools\Renderer\InspectionRendererInterface;
use Zend\View\Model\ModelInterface;

/**
 * Tests for {@see \Roave\DeveloperTools\Renderer\BaseRenderer}
 *
 * @covers \Roave\DeveloperTools\Renderer\BaseRenderer
 */
class BaseInspectionRendererTest extends PHPUnit_Framework_TestCase
{
    public function testAcceptsOnlyAggregateInspection()
    {
        $renderer = $this->getRenderer();

        $this->assertTrue($renderer->canRender($this->getMock(InspectionInterface::class)));
        $this->assertTrue($renderer->canRender($this->getMock(TimeInspection::class, [], [], '', false)));
        $this->assertTrue($renderer->canRender($this->getMock(AggregateInspection::class, [], [], '', false)));
    }

    public function testRender()
    {
        $renderer   = $this->getRenderer();
        /* @var $inspection InspectionInterface */
        $inspection = $this->getMock(InspectionInterface::class);
        $viewModel  = $renderer->render($inspection);

        $this->assertInstanceOf(ModelInterface::class, $viewModel);

        $this->assertSame($inspection, $viewModel->getVariable(BaseInspectionRenderer::PARAM_INSPECTION));
    }

    /**
     * @return InspectionRendererInterface
     */
    public function getRenderer()
    {
        return $this->getMockForAbstractClass(BaseInspectionRenderer::class);
    }
}<commit_msg>Re-designing base inspection renderer test for extensibility<commit_after><?php
/*
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * This software consists of voluntary contributions made by many individuals
 * and is licensed under the MIT license.
 */

namespace RoaveTest\DeveloperTools\Renderer;

use PHPUnit_Framework_TestCase;
use Roave\DeveloperTools\Inspection\AggregateInspection;
use Roave\DeveloperTools\Inspection\InspectionInterface;
use Roave\DeveloperTools\Inspection\TimeInspection;
use Roave\DeveloperTools\Renderer\BaseInspectionRenderer;
use Roave\DeveloperTools\Renderer\InspectionRendererInterface;
use Zend\View\Model\ModelInterface;

/**
 * Tests for {@see \Roave\DeveloperTools\Renderer\BaseRenderer}
 *
 * @covers \Roave\DeveloperTools\Renderer\BaseRenderer
 */
class BaseInspectionRendererTest extends PHPUnit_Framework_TestCase
{
    /**
     * @param InspectionInterface $inspection
     *
     * @dataProvider getSupportedInspections
     */
    public function testAcceptedModels(InspectionInterface $inspection)
    {
        $this->assertTrue($this->getRenderer()->canRender($inspection));
    }

    /**
     * @param InspectionInterface|null $inspection
     *
     * @dataProvider getUnSupportedInspections
     */
    public function testRefusedModels(InspectionInterface $inspection = null)
    {
        if (null === $inspection) {
            // just a hack since PHPUnit does not allow empty data providers
            $this->assertNull($inspection, 'Renderer supports all inspection types');

            return;
        }

        $this->assertFalse($this->getRenderer()->canRender($inspection));
    }

    /**
     * @param InspectionInterface $inspection
     *
     * @dataProvider getSupportedInspections
     */
    public function testRender(InspectionInterface $inspection)
    {
        $viewModel = $this->getRenderer()->render($inspection);

        $this->assertInstanceOf(ModelInterface::class, $viewModel);
        $this->assertSame($inspection, $viewModel->getVariable(BaseInspectionRenderer::PARAM_INSPECTION));
    }

    /**
     * @return InspectionRendererInterface
     */
    public function getRenderer()
    {
        return $this->getMockForAbstractClass(BaseInspectionRenderer::class);
    }

    /**
     * @return InspectionInterface[][]
     */
    public function getSupportedInspections()
    {
        return [
            [$this->getMock(InspectionInterface::class)],
            [$this->getMock(TimeInspection::class, [], [], '', false)],
            [$this->getMock(AggregateInspection::class, [], [], '', false)],
        ];
    }

    /**
     * @return InspectionInterface[][]|null[][]
     */
    public function getUnSupportedInspections()
    {
        return [
            [null],
        ];
    }
}
{'fraction_non_alphanumeric': 0.10150130548302871, 'fraction_numerical': 0.0, 'mean_word_length': 3.92289156626506, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3021398', 'n_tokens_mistral': 1734, 'n_tokens_neox': 1601, 'n_words': 441}