<commit_before><?php

namespace Test\Phpatterns\Structural\Decorator;

use Phpatterns\Structural\Decorator;
use Phpatterns\Structural\Decorator\Bread;
use Phpatterns\Structural\Decorator\Topping;

class DecoratorTest extends \PHPUnit_Framework_TestCase
{
    /**
     * Decorator pattern requirement: the decorator must implement BreadInterface interface
     */
    public function testToppingDecoratorImplementsBreadInterface()
    {
        $this->assertTrue(
            is_subclass_of(
                Decorator\AbstractToppingDecorator::class,
                Decorator\BreadInterface::class
            )
        );
    }

    /**
     * Decorator pattern requirement: the decorator must be type hinted
     * (with BreadInterface interface in our case)
     *
     * @expectedException \PHPUnit_Framework_Error
     */
    public function testToppingDecoratorConstructor()
    {
        $this->getMockForAbstractClass(
            Decorator\AbstractToppingDecorator::class,<commit_msg>Modified Decorator test to support PHP 7 new exceptions.<commit_after><?php

namespace Test\Phpatterns\Structural\Decorator;

use Phpatterns\Structural\Decorator;
use Phpatterns\Structural\Decorator\Bread;
use Phpatterns\Structural\Decorator\Topping;

class DecoratorTest extends \PHPUnit_Framework_TestCase
{
    /**
     * Decorator pattern requirement: the decorator must implement BreadInterface interface
     */
    public function testToppingDecoratorImplementsBreadInterface()
    {
        $this->assertTrue(
            is_subclass_of(
                Decorator\AbstractToppingDecorator::class,
                Decorator\BreadInterface::class
            )
        );
    }

    /**
     * Decorator pattern requirement: the decorator must be type hinted
     * (with BreadInterface interface in our case)
     *
     */
    public function testToppingDecoratorConstructor()
    {
        /*
         * In PHP 7, a TypeError exception is thrown when arguments' types
         * passed to a function do not match their corresponding declared
         * parameters.
         * see http://php.net/manual/en/class.typeerror.php
         */
        if (version_compare(PHP_VERSION, '7', '>=')) {
            $this->setExpectedException('TypeError');
        } else {
            $this->setExpectedException('PHPUnit_Framework_Error');
        }

        $this->getMockForAbstractClass(
            Decorator\AbstractToppingDecorator::class,
{'fraction_non_alphanumeric': 0.08039376538146022, 'fraction_numerical': 0.0012305168170631665, 'mean_word_length': 2.75808936825886, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3739036', 'n_tokens_mistral': 675, 'n_tokens_neox': 662, 'n_words': 137}