Skip to content
This repository has been archived by the owner on Jul 28, 2022. It is now read-only.

Fix phpunit #625

Merged
merged 1 commit into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/qa_client_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ run_test() {
echo "Running tests from ./${1}"
echo "--"

SYMFONY_DEPRECATIONS_HELPER=weak php -d memory_limit=-1 bin/phpunit -c ${1} ${extra} --log-junit build/junit/`basename ${1}`.xml
SYMFONY_DEPRECATIONS_HELPER=weak php -d memory_limit=-1 vendor/bin/phpunit -c ${1} ${extra} --log-junit build/junit/`basename ${1}`.xml

status=$?

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"behat/mink-selenium2-driver": "^1.3.1",
"phing/phing": "^2.16",
"symfony/dotenv": "^4.0",
"symfony/phpunit-bridge": "^4.0",
"symfony/phpunit-bridge": "^5.1",
"symfony/profiler-pack": "^1.0"
},

Expand Down
32 changes: 1 addition & 31 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
>

<php>
<ini name="error_reporting" value="-1" />
<server name="KERNEL_CLASS" value="AppKernel" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
<server name="KERNEL_CLASS" value="App\Kernel" />

<!-- ###+ doctrine/doctrine-bundle ### -->
<!-- Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url -->
Expand Down Expand Up @@ -42,34 +40,6 @@
</testsuite>
</testsuites>

<!--
<php>
<server name="KERNEL_DIR" value="/path/to/your/app/" />

<!-- ###+ doctrine/doctrine-bundle ### -->
<!-- Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url -->
<!-- For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db" -->
<!-- For a PostgreSQL database, use: "postgresql://db_user:[email protected]:5432/db_name?serverVersion=11&charset=utf8" -->
<!-- IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml -->
<env name="DATABASE_URL" value="mysql://db_user:[email protected]:3306/db_name?serverVersion=5.7"/>
<!-- ###- doctrine/doctrine-bundle ### -->

<!-- ###+ symfony/swiftmailer-bundle ### -->
<!-- For Gmail as a transport, use: "gmail://username:password@localhost" -->
<!-- For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode=" -->
<!-- Delivery is disabled by default via "null://localhost" -->
<env name="MAILER_URL" value="null://localhost"/>
<!-- ###- symfony/swiftmailer-bundle ### -->

<!-- ###+ symfony/framework-bundle ### -->
<env name="APP_ENV" value="dev"/>
<env name="APP_SECRET" value="925b958e51a78ee7a9edd86cf9778089"/>
<!-- env name="TRUSTED_PROXIES" value="127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16" -->
<!-- env name="TRUSTED_HOSTS" value="'^(localhost|example\.com)$'" -->
<!-- ###- symfony/framework-bundle ### -->
</php>
-->

<filter>
<whitelist>
<directory>../src</directory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
* file that was distributed with this source code.
*/

namespace Sonata\Bundle\QABundle\Tests;
namespace Tests\Sonata\Bundle\QABundle;
Copy link
Member

Choose a reason for hiding this comment

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

Would prefer Sonata\Tests over Tests\Sonata because the vendor is Sonata

Copy link
Member Author

Choose a reason for hiding this comment

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

I want create sandbox as predefine application, ready to use where people can modify them. I replace tests becouse it is default directory for it. I think will be nice use Tests\Sonata without Bundle\QABundle, mybe even split it to seperate namespace like Tests\Sonata\News. I prefer using Test\Sonata becouse people can delete them without change in composer.json (this change require use composer update).

"autoload-dev": {
    "psr-4": {
        "Tests\\": "tests/"
    }
},

Copy link
Member Author

Choose a reason for hiding this comment

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

BTW, should we merge QABundle with DemoBundle?

Copy link
Member

Choose a reason for hiding this comment

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

@core23 @wbloszyk

You can do

"autoload-dev": {
    "psr-4": {
        "Sonata\\Tests\\": "tests/"
    }
},

and then tests/Bundle/QABundle/..., without the Sonata folder.

isn't it ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I want avoid modify composer.json becouse if people delete tests then they have to remove it from composer.json too and run composer update to clear it on vendor/composer files.

Copy link
Member

Choose a reason for hiding this comment

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

IMO having standard composer .json namespaces is better.

Copy link
Member Author

Choose a reason for hiding this comment

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

IMO files from vendor directory should be trait as sonata files. Files from other directory should be trait as people files to keep it as easy is possible to edit. I dont think user will want edit composer after remove files.

@VincentLanglet What when someone add own tests? Then namespace Sonata\Tests will be require.

@VincentLanglet @core23 @jordisala1991 WDYT?
My sugestion is:

  1. move AppBundle to src (App)
  2. move QABundle to DemoBundle
  3. split DemoBundle to DemoBundle and sonata-project instalator packege/bundle
  4. improve DemoBundle

Copy link
Member

Choose a reason for hiding this comment

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

[...] if people delete tests then they have to remove it from composer.json too and run composer update to clear it on vendor/composer files.

This is a sandbox project. We should risk this and follow vendor-prefixed namespaces (Sonata\Tests).


use Symfony\Bundle\FrameworkBundle\Client;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\StreamOutput;
Expand All @@ -29,7 +29,7 @@ abstract class CommandTestCase extends WebTestCase
/**
* Runs a command and returns it output.
*/
public function runCommand(Client $client, $command, $exceptionOnExitCode = true)
public function runCommand(KernelBrowser $client, $command, $exceptionOnExitCode = true)
{
$application = new Application($client->getKernel());
$application->setAutoExit(false);
Expand Down Expand Up @@ -57,7 +57,7 @@ public function runCommand(Client $client, $command, $exceptionOnExitCode = true
/**
* @return string
*/
public function getConsoleLocation(Client $client)
public function getConsoleLocation(KernelBrowser $client)
{
return sprintf('%s/console', $client->getContainer()->getParameter('kernel.root_dir'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace Sonata\Bundle\QABundle\Tests;
namespace Tests\Sonata\Bundle\QABundle;

class ListCommandTest extends CommandTestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace Sonata\Bundle\QABundle\Tests;
namespace Tests\Sonata\Bundle\QABundle;

class SonataAdminExplainCommandTest extends CommandTestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace Sonata\Bundle\QABundle\Tests;
namespace Tests\Sonata\Bundle\QABundle;

class SonataAdminListCommandTest extends CommandTestCase
{
Expand All @@ -25,8 +25,8 @@ public function testListing()
foreach (self::getAdminList() as $def) {
list($id, $class) = $def;

$this->assertContains($id, $output);
$this->assertContains($class, $output);
$this->assertStringContainsString($id, $output);
$this->assertStringContainsString($class, $output);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace Sonata\Bundle\QABundle\Tests;
namespace Tests\Sonata\Bundle\QABundle;

class SonataBlockDebugCommandTest extends CommandTestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace Sonata\Bundle\QABundle\Tests;
namespace Tests\Sonata\Bundle\QABundle;

class SonataCacheFlushAllCommandTest extends CommandTestCase
{
Expand All @@ -21,6 +21,6 @@ public function testFlushAll()
$output = $this->runCommand($client, 'sonata:cache:flush-all', false);

$this->assertNotNull($output);
$this->assertNotContains('FAILED!', $output);
$this->assertStringNotContainsString('FAILED!', $output);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace Sonata\Bundle\QABundle\Tests;
namespace Tests\Sonata\Bundle\QABundle;

class SonataCacheFlushCommandTest extends CommandTestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace Sonata\Bundle\QABundle\Tests;
namespace Tests\Sonata\Bundle\QABundle;

class SonataEasyExtendsDumpMappingCommandTest extends CommandTestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace Sonata\Bundle\QABundle\Tests;
namespace Tests\Sonata\Bundle\QABundle;

class SonataMediaAddCommandTest extends CommandTestCase
{
Expand All @@ -34,7 +34,7 @@ public function testMediaAdd()
sprintf('%s/../src/Sonata/Bundle/DemoBundle/DataFixtures/data/files/IMG_0003.JPG', $baseFolder)
));

$this->assertContains('Add a new media - context: product_catalog, provider: sonata.media.provider.image, content: ', $output);
$this->assertContains('done!', $output);
$this->assertStringContainsString('Add a new media - context: product_catalog, provider: sonata.media.provider.image, content: ', $output);
$this->assertStringContainsString('done!', $output);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace Sonata\Bundle\QABundle\Tests;
namespace Tests\Sonata\Bundle\QABundle;

class SonataMediaRefreshMediaCommandTest extends CommandTestCase
{
Expand All @@ -27,6 +27,6 @@ public function testRefresh($id)
'default'
));

$this->assertContains('Done!', $output);
$this->assertStringContainsString('Done!', $output);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace Sonata\Bundle\QABundle\Tests;
namespace Tests\Sonata\Bundle\QABundle;

class SonataMediaSyncCommandTest extends CommandTestCase
{
Expand All @@ -27,6 +27,6 @@ public function testRefresh($id)
'default'
));

$this->assertContains('Done (total ', $output);
$this->assertStringContainsString('Done (total ', $output);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace Sonata\Bundle\QABundle\Tests;
namespace Tests\Sonata\Bundle\QABundle;

class SonataNewsSyncCommentTest extends CommandTestCase
{
Expand All @@ -21,6 +21,6 @@ public function testRefresh()

$output = $this->runCommand($client, 'sonata:news:sync-comments-count');

$this->assertContains('done!', $output);
$this->assertStringContainsString('done!', $output);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace Sonata\Bundle\QABundle\Tests;
namespace Tests\Sonata\Bundle\QABundle;

class SonataNotificationCleanUpCommandTest extends CommandTestCase
{
Expand All @@ -21,6 +21,6 @@ public function testRefresh()

$output = $this->runCommand($client, 'sonata:notification:cleanup');

$this->assertContains('done!', $output);
$this->assertStringContainsString('done!', $output);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace Sonata\Bundle\QABundle\Tests;
namespace Tests\Sonata\Bundle\QABundle;

class SonataNotificationHandlerListCommandTest extends CommandTestCase
{
Expand All @@ -21,13 +21,13 @@ public function testRefresh()

$output = $this->runCommand($client, 'sonata:notification:list-handler');

$this->assertContains('done!', $output);
$this->assertStringContainsString('done!', $output);

foreach (self::getConsumerList() as $def) {
list($name, $id) = $def;

$this->assertContains($name, $output);
$this->assertContains($id, $output);
$this->assertStringContainsString($name, $output);
$this->assertStringContainsString($id, $output);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace Sonata\Bundle\QABundle\Tests;
namespace Tests\Sonata\Bundle\QABundle;

class SonataNotificationListQueuesCommandTest extends CommandTestCase
{
Expand All @@ -21,6 +21,6 @@ public function testCommand()

$output = $this->runCommand($client, 'sonata:notification:list-queues');

$this->assertContains('The backend class Sonata\\NotificationBundle\\Backend\\PostponeRuntimeBackend does not provide multiple queues.', $output);
$this->assertStringContainsString('The backend class Sonata\\NotificationBundle\\Backend\\PostponeRuntimeBackend does not provide multiple queues.', $output);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace Sonata\Bundle\QABundle\Tests;
namespace Tests\Sonata\Bundle\QABundle;

class SonataNotificationRestartCommandTest extends CommandTestCase
{
Expand All @@ -21,6 +21,6 @@ public function testRefresh()

$output = $this->runCommand($client, 'sonata:notification:restart');

$this->assertContains('Nothing to restart, bye.', $output);
$this->assertStringContainsString('Nothing to restart, bye.', $output);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,25 @@
* file that was distributed with this source code.
*/

namespace Sonata\Bundle\QABundle\Tests;
namespace Tests\Sonata\Bundle\QABundle;

class SonataNotificationStartCommandTest extends CommandTestCase
{
public function testRefresh()
{
$client = self::createClient();

/*
// TODO: find why suspended tests
$output = $this->runCommand($client, 'sonata:notification:start');

$this->assertContains('done!', $output);
$this->assertStringContainsString('done!', $output);

foreach (self::getConsumerList() as $def) {
list($name) = $def;

$this->assertContains($name, $output);
$this->assertStringContainsString($name, $output);
}
*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace Sonata\Bundle\QABundle\Tests;
namespace Tests\Sonata\Bundle\QABundle;

class SonataPageCleanSnapshotCommandTest extends CommandTestCase
{
Expand All @@ -21,6 +21,6 @@ public function testRefresh()

$output = $this->runCommand($client, sprintf('sonata:page:cleanup-snapshots --site=all --base-console=%s', $this->getConsoleLocation($client)));

$this->assertContains('done!', $output);
$this->assertStringContainsString('done!', $output);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace Sonata\Bundle\QABundle\Tests;
namespace Tests\Sonata\Bundle\QABundle;

class SonataPageCreateSiteCommandTest extends CommandTestCase
{
Expand All @@ -32,7 +32,7 @@ public function testCreateSite()
' --no-interaction'
);

$this->assertContains('Creating website with the following information :', $output);
$this->assertContains('Site created !', $output);
$this->assertStringContainsString('Creating website with the following information :', $output);
$this->assertStringContainsString('Site created !', $output);
}
}
Loading