contao / test-case

[READ-ONLY] Contao Test Case
6 stars 4 forks source link

RuntimeException: Cannot find the Contao configuration file #17

Closed Ernestopheles closed 1 year ago

Ernestopheles commented 1 year ago

PHPUnit returns this error testing my extension at the framewok mocking.

Contao 4.13.23 PHP8.1 PHPUnit 9.5 test-case 5.1

Debug shows that in ContaoTestCase loadDefaultConfiguration() switch goes into the default case.

My Testcase:

<?php

declare(strict_types=1);

namespace Nahati\ContaoIsotopeStockBundle\Tests\Unit\Helper;

use Contao\TestCase\ContaoTestCase;
use nahati\ContaoIsotopeStockBundle\Helper\Helper;
use Isotope\Model\Product\Standard;

/**
 * Test the Helper class.
 *
 * @covers \nahati\ContaoIsotopeStockBundle\Helper\Helper
 */
class HelperTest extends ContaoTestCase
{
    private $helper;

    protected function setUp(): void
    {
        parent::setUp();

        // Mocks a Symfony container with the default configuration of the Contao core extension
        $container = $this->getContainerWithContaoConfiguration();

        // Check if the container has been created
        $this->assertInstanceOf('\Symfony\Component\DependencyInjection\ContainerBuilder', $container);

        // Check if the container is working
        $this->assertEquals($container->getParameter('contao.upload_path'), "files");

        $framework = $this->mockContaoFramework();

        // Check if the framework has been created
        $this-assertInstanceOf('\Contao\CoreBundle\Framework\ContaoFramework&\PHPUnit\Framework\MockObject\MockObject', $framework);

        $this->helper = new Helper();
    }

    public function testTrueIsTrue()
    {
        $foo = true;
        $this->assertTrue($foo);
    }
}
Ernestopheles commented 1 year ago

Closed as Error ocurres as of non compliant version of test-case