Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Can't use Laravel's built in DB Mock in a Codeception run #19

Open
@timbroder

Description

@timbroder

What are you trying to achieve?

Use Laravel's built in DB Mock in a Codeception run

Note: This works in 2.2.9 but breaks in 2.2.10

What do you get instead?

./vendor/bin/codecept run -f -d unit Traits/
Codeception PHP Testing Framework v2.2.10
Powered by PHPUnit 4.8.27 by Sebastian Bergmann and contributors.

  Rebuilding UnitTester...

Unit Tests (7) ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Modules: Laravel5, Asserts, \Helper\Unit, Mockery, Db
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
✔ DatabaseToolsUnitTest: Date_modify_works_for_postgres (0.06s)


  [BadMethodCallException]
  Method Mockery_0_Illuminate_Database_DatabaseManager::getConnections() does not exist on this mock object


Exception trace:
 () at /Users/timbroder/workspace/kidfund/web/vendor/mockery/mockery/library/Mockery/Loader/EvalLoader.php(16) : eval()'d code:709
 Mockery_0_Illuminate_Database_DatabaseManager->_mockery_handleMethodCall() at /Users/timbroder/workspace/kidfund/web/vendor/mockery/mockery/library/Mockery/Loader/EvalLoader.php(16) : eval()'d code:857
 Mockery_0_Illuminate_Database_DatabaseManager->getConnections() at /Users/timbroder/workspace/kidfund/web/vendor/codeception/codeception/src/Codeception/Module/Laravel5.php:203
 Codeception\Module\Laravel5->_after() at /Users/timbroder/workspace/kidfund/web/vendor/codeception/codeception/src/Codeception/Subscriber/Module.php:68
 Codeception\Subscriber\Module->after() at n/a:n/a
 call_user_func() at /Users/timbroder/workspace/kidfund/web/vendor/symfony/event-dispatcher/EventDispatcher.php:174
 Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() at /Users/timbroder/workspace/kidfund/web/vendor/symfony/event-dispatcher/EventDispatcher.php:43
 Symfony\Component\EventDispatcher\EventDispatcher->dispatch() at /Users/timbroder/workspace/kidfund/web/vendor/codeception/codeception/src/Codeception/PHPUnit/Listener.php:126
 Codeception\PHPUnit\Listener->fire() at /Users/timbroder/workspace/kidfund/web/vendor/codeception/codeception/src/Codeception/PHPUnit/Listener.php:112
 Codeception\PHPUnit\Listener->endTest() at /Users/timbroder/workspace/kidfund/web/vendor/phpunit/phpunit/src/Framework/TestResult.php:340
 PHPUnit_Framework_TestResult->endTest() at /Users/timbroder/workspace/kidfund/web/vendor/phpunit/phpunit/src/Framework/TestResult.php:733
 PHPUnit_Framework_TestResult->run() at /Users/timbroder/workspace/kidfund/web/vendor/phpunit/phpunit/src/Framework/TestCase.php:724
 PHPUnit_Framework_TestCase->run() at /Users/timbroder/workspace/kidfund/web/vendor/phpunit/phpunit/src/Framework/TestSuite.php:747
 PHPUnit_Framework_TestSuite->run() at /Users/timbroder/workspace/kidfund/web/vendor/codeception/codeception/src/Codeception/PHPUnit/Runner.php:106
 Codeception\PHPUnit\Runner->doEnhancedRun() at /Users/timbroder/workspace/kidfund/web/vendor/codeception/codeception/src/Codeception/SuiteManager.php:157
 Codeception\SuiteManager->run() at /Users/timbroder/workspace/kidfund/web/vendor/codeception/codeception/src/Codeception/Codecept.php:184
 Codeception\Codecept->runSuite() at /Users/timbroder/workspace/kidfund/web/vendor/codeception/codeception/src/Codeception/Codecept.php:153
 Codeception\Codecept->run() at /Users/timbroder/workspace/kidfund/web/vendor/codeception/codeception/src/Codeception/Command/Run.php:288
 Codeception\Command\Run->execute() at /Users/timbroder/workspace/kidfund/web/vendor/symfony/console/Command/Command.php:259
 Symfony\Component\Console\Command\Command->run() at /Users/timbroder/workspace/kidfund/web/vendor/symfony/console/Application.php:847
 Symfony\Component\Console\Application->doRunCommand() at /Users/timbroder/workspace/kidfund/web/vendor/symfony/console/Application.php:192
 Symfony\Component\Console\Application->doRun() at /Users/timbroder/workspace/kidfund/web/vendor/symfony/console/Application.php:123
 Symfony\Component\Console\Application->run() at /Users/timbroder/workspace/kidfund/web/vendor/codeception/codeception/src/Codeception/Application.php:103
 Codeception\Application->run() at /Users/timbroder/workspace/kidfund/web/vendor/codeception/codeception/codecept:36

Provide test source code if related

     /**
     * @test
     */
    public function date_modify_works_for_postgres()
    {
        DB::shouldReceive('getDriverName')
            ->once()
            ->andReturn('pgsql');

        $return = $this->dateModify('field_name', '10', '-', 'month');

        $this->assertEquals("field_name - INTERVAL '10' month", $return);
    }

Details

  • Codeception version: 2.2.10
  • PHP Version: 2.3.5
  • Operating System: OSX 10.12.6
  • Installation type: Composer
  • List of installed packages gist
  • Suite configuration: Using Codeceptions tests

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions