Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPUnit Doesn't Clear Caches #2053

Closed
3 tasks done
ConnorVG opened this issue Aug 13, 2016 · 7 comments
Closed
3 tasks done

PHPUnit Doesn't Clear Caches #2053

ConnorVG opened this issue Aug 13, 2016 · 7 comments

Comments

@ConnorVG
Copy link
Contributor

Before submitting your issue, please make sure that you've checked the checkboxes below.

  • I am running the latest release version of Cachet.
  • I am running at least PHP 5.5.9. You can check this by running php -v.
  • I have ran rm -rf bootstrap/cache/*.

Expected behaviour

After running phpunit, I expect my environment to not be mutated.

Actual behaviour

PHPUnit bootstraps it's environment and never clears it's cache once completed (application stays in testing).

Steps to reproduce

  1. Have a default installation (pre-setup and seeded)
  2. Run vendor/bin/phpunit
  3. Go to your site, notice you're now on /setup
  4. Run artisan env and notice you're now in testing
@GrahamCampbell
Copy link
Contributor

Yeh, this is a known issue, but I've never really cared enough to fix it. :trollface:

Feel free to have a go I guess. ;)

@ConnorVG
Copy link
Contributor Author

It's annoying af...

@yoyosan
Copy link
Contributor

yoyosan commented Aug 13, 2016

artisan config:clear fixes it. But it should be automatic IMHO.

@GrahamCampbell
Copy link
Contributor

I imagine we're also messing with our settings cache (not the same as config).

@ConnorVG
Copy link
Contributor Author

ConnorVG commented Aug 13, 2016

Hmm, we could always add a listener... Like:

<?php

/*
 * This file is part of Cachet.
 *
 * (c) Alt Three Services Limited
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CachetHQ\Tests\Cachet;

use PHPUnit_Framework_BaseTestListener;
use PHPUnit_Framework_TestSuite;

/**
 * This is the test listener class.
 *
 * @author Connor S. Parks <connor@connorvg.tv>
 */
class TestListener extends PHPUnit_Framework_BaseTestListener
{
    /**
     * A test suite ended.
     *
     * @since Method available since Release 2.2.0
     *
     * @param \PHPUnit_Framework_TestSuite $suite
     *
     * @return void
     */
    public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
    {
        if ($suite->getName() !== 'Cachet Test Suite') {
            return;
        }

        foreach (glob(__DIR__.'/../bootstrap/cache/*.php') as $file) {
            unlink($file);
        }
    }
}
<listeners>
    <listener class="CachetHQ\Tests\Cachet\TestListener" file="./tests/TestListener.php" />
</listeners>

@ConnorVG
Copy link
Contributor Author

Lul :trollface:

@ConnorVG
Copy link
Contributor Author

As @GrahamCampbell noted, it actually needs all cache files cleared. Not just X or Y.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants