EDITS: 1
I need to test an Eloquent model by touching the database and I Have this test case:
use Mockery as m;
use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Database\Connectors\ConnectionFactory;
use Illuminate\Database\DatabaseManager;
use Illuminate\Database\ConnectionResolver;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Artisan;
use Illuminate\Container\Container;
use Illuminate\Config\Repository as Config;
use Illuminate\Database\Console\Migrations\MigrateCommand;
use Illuminate\Database\Migrations\Migrator;
use Illuminate\Database\Migrations\DatabaseMigrationRepository;
use Illuminate\Filesystem\Filesystem;
class Module extends Eloquent {
protected $table = 'modules';
protected $fillable = array('name');
}
class UserTest extends PHPUnit_Framework_TestCase{
public function setUp()
{
$this->modelName = 'My Model Name';
$this->migrationsTable = 'migrations';
$this->environment = 'testing';
$this->connectionName = 'postgresql'; // postgresql memory
date_default_timezone_set('UTC');
$this->app = new Application;
$this->migrationPath = __DIR__ . '/../../migrations';
$this->app->instance('path', __DIR__);
$this->app->instance('config', $config = new Config(
$this->app->getConfigLoader(), $this->environment
));
$this->app['config']['app'] = array( 'debug' => true,
'url' => 'http://localhost',
'timezone' => 'UTC',
'locale' => 'en',
'key' => 'YourSecretKey!!!',
'providers' => array(
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
'Illuminate\Cache\CacheServiceProvider',
'Illuminate\Session\CommandsServiceProvider',
'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
'Illuminate\Routing\ControllerServiceProvider',
'Illuminate\Cookie\CookieServiceProvider',
'Illuminate\Database\DatabaseServiceProvider',
'Illuminate\Encryption\EncryptionServiceProvider',
'Illuminate\Filesystem\FilesystemServiceProvider',
'Illuminate\Hashing\HashServiceProvider',
'Illuminate\Html\HtmlServiceProvider',
'Illuminate\Log\LogServiceProvider',
'Illuminate\Mail\MailServiceProvider',
'Illuminate\Database\MigrationServiceProvider',
'Illuminate\Pagination\PaginationServiceProvider',
'Illuminate\Queue\QueueServiceProvider',
'Illuminate\Redis\RedisServiceProvider',
'Illuminate\Remote\RemoteServiceProvider',
'Illuminate\Auth\Reminders\ReminderServiceProvider',
'Illuminate\Database\SeedServiceProvider',
'Illuminate\Session\SessionServiceProvider',
'Illuminate\Translation\TranslationServiceProvider',
'Illuminate\Validation\ValidationServiceProvider',
'Illuminate\View\ViewServiceProvider',
'Illuminate\Workbench\WorkbenchServiceProvider',
),
'manifest' => '/meta',
'aliases' => array(
'App' => 'Illuminate\Support\Facades\App',
'Artisan' => 'Illuminate\Support\Facades\Artisan',
'Auth' => 'Illuminate\Support\Facades\Auth',
'Blade' => 'Illuminate\Support\Facades\Blade',
'Cache' => 'Illuminate\Support\Facades\Cache',
'ClassLoader' => 'Illuminate\Support\ClassLoader',
'Config' => 'Illuminate\Support\Facades\Config',
'Controller' => 'Illuminate\Routing\Controller',
'Cookie' => 'Illuminate\Support\Facades\Cookie',
'Crypt' => 'Illuminate\Support\Facades\Crypt',
'DB' => 'Illuminate\Support\Facades\DB',
'Eloquent' => 'Illuminate\Database\Eloquent\Model',
'Event' => 'Illuminate\Support\Facades\Event',
'File' => 'Illuminate\Support\Facades\File',
'Form' => 'Illuminate\Support\Facades\Form',
'Hash' => 'Illuminate\Support\Facades\Hash',
'HTML' => 'Illuminate\Support\Facades\HTML',
'Input' => 'Illuminate\Support\Facades\Input',
'Lang' => 'Illuminate\Support\Facades\Lang',
'Log' => 'Illuminate\Support\Facades\Log',
'Mail' => 'Illuminate\Support\Facades\Mail',
'Paginator' => 'Illuminate\Support\Facades\Paginator',
'Password' => 'Illuminate\Support\Facades\Password',
'Queue' => 'Illuminate\Support\Facades\Queue',
'Redirect' => 'Illuminate\Support\Facades\Redirect',
'Redis' => 'Illuminate\Support\Facades\Redis',
'Request' => 'Illuminate\Support\Facades\Request',
'Response' => 'Illuminate\Support\Facades\Response',
'Route' => 'Illuminate\Support\Facades\Route',
'Schema' => 'Illuminate\Support\Facades\Schema',
'Seeder' => 'Illuminate\Database\Seeder',
'Session' => 'Illuminate\Support\Facades\Session',
'SSH' => 'Illuminate\Support\Facades\SSH',
'Str' => 'Illuminate\Support\Str',
'URL' => 'Illuminate\Support\Facades\URL',
'Validator' => 'Illuminate\Support\Facades\Validator',
'View' => 'Illuminate\Support\Facades\View',
),
);
$this->app['config']['database'] = array('connections' => array(
'memory' => array(
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => ''
),
'postgresql' => array(
'driver' => 'pgsql',
'host' => 'localhost',
'database' => 'antoniocarlosribeiro',
'username' => 'antoniocarlos',
'password' => 'basswort',
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
),
)
);
$this->factory = new ConnectionFactory($this->app);
$this->manager = new DatabaseManager($this->app, $this->factory);
$this->migrateCommand = new MigrateCommand(
new Migrator(
new DatabaseMigrationRepository(
$this->manager,
$this->migrationsTable
),
$this->manager,
new Filesystem
),
$this->migrationPath
);
$this->model = new Module;
$this->model->setConnectionResolver($this->manager);
$this->model->setConnection($this->connectionName);
// $this->app->instance('artisan', $artisan = new Artisan($this->app));
// $this->app['artisan']->add($this->migrateCommand);
// $this->app['artisan']->call('migrate:refresh');
}
public function tearDown()
{
m::close();
}
public function testCreated()
{
$this->assertInstanceOf('Illuminate\Database\Eloquent\Model', $this->model);
}
public function testDeleteCreateSelect()
{
$this->model->on($this->connectionName)->where('name', $this->modelName)->delete();
$this->model->on($this->connectionName)->insert( array('name' => $this->modelName, 'created_at' => new DateTime, 'updated_at' => new DateTime) );
$this->assertEquals($this->model->where('name', $this->modelName)->first()->name, $this->modelName);
}
}
This thing is working fine. Delete, insert and select are working and hitting the database, so I get a green.
I plan to develop the tests on database, to take a look at the data and then move to :memory:, for speed.
The problem now is that I need Artisan to be working, so I can migrate:refresh on every run, but if I enable those 3 artisan lines it goes down to a recursive call to artisan:
PHP 1. {main}() /usr/share/phpunit/vendor/phpunit/phpunit/composer/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/share/phpunit/vendor/phpunit/phpunit/composer/bin/phpunit:63
PHP 3. PHPUnit_TextUI_Command->run() /usr/share/phpunit/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:129
PHP 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/phpunit/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:176
PHP 5. PHPUnit_Framework_TestSuite->run() /usr/share/phpunit/vendor/phpunit/phpunit/PHPUnit/TextUI/TestRunner.php:349
PHP 6. PHPUnit_Framework_TestSuite->run() /usr/share/phpunit/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:705
PHP 7. PHPUnit_Framework_TestSuite->runTest() /usr/share/phpunit/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:745
PHP 8. PHPUnit_Framework_TestCase->run() /usr/share/phpunit/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:775
PHP 9. PHPUnit_Framework_TestResult->run() /usr/share/phpunit/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:783
PHP 10. PHPUnit_Framework_TestCase->runBare() /usr/share/phpunit/vendor/phpunit/phpunit/PHPUnit/Framework/TestResult.php:648
PHP 11. UserTest->setUp() /usr/share/phpunit/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:835
PHP 12. Illuminate\Foundation\Artisan->add() /dev.app/workbench/antonio/package/tests/Package/UserTest.php:174
PHP 13. Illuminate\Foundation\Artisan->__call() /dev.app/workbench/antonio/package/tests/Package/UserTest.php:174
PHP 14. call_user_func_array() /dev.app/workbench/antonio/package/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php:82
PHP 15. Illuminate\Foundation\Artisan->add() /dev.app/workbench/antonio/package/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php:82
PHP 16. Illuminate\Foundation\Artisan->__call() /dev.app/workbench/antonio/package/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php:0
PHP 17. call_user_func_array() /dev.app/workbench/antonio/package/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php:82
PHP 18. Illuminate\Foundation\Artisan->add() /dev.app/workbench/antonio/package/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php:82
PHP 19. Illuminate\Foundation\Artisan->__call() /dev.app/workbench/antonio/package/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php:0
PHP 20. call_user_func_array() /dev.app/workbench/antonio/package/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php:82
PHP 21. Illuminate\Foundation\Artisan->add() /dev.app/workbench/antonio/package/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php:82
PHP 22. Illuminate\Foundation\Artisan->__call() /dev.app/workbench/antonio/package/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php:0
PHP 23. call_user_func_array() /dev.app/workbench/antonio/package/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php:82
PHP 24. Illuminate\Foundation\Artisan->add() /dev.app/workbench/antonio/package/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php:82
PHP 25. Illuminate\Foundation\Artisan->__call() /dev.app/workbench/antonio/package/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php:0
PHP 26. call_user_func_array() /dev.app/workbench/antonio/package/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php:82
PHP 27. Illuminate\Foundation\Artisan->add() /dev.app/workbench/antonio/package/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php:82
PHP 28. Illuminate\Foundation\Artisan->__call() /dev.app/workbench/antonio/package/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php:0
PHP 29. call_user_func_array() /dev.app/workbench/antonio/package/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php:82
PHP 30. Illuminate\Foundation\Artisan->add() /dev.app/workbench/antonio/package/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php:82
PHP 31. Illuminate\Foundation\Artisan->__call() /dev.app/workbench/antonio/package/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php:0
PHP 32. call_user_func_array() /dev.app/workbench/antonio/package/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php:82
Any leads on instantiating and using Artisan correctly?
Mocking a connection
Mocking a database connection gets complicated (I've done it before, it's messy!).
This is some code I had working in a unit test after a ton of trial and error some months ago:
Illuminate\Database\Eloquent\Model::setConnectionResolver($resolver = m::mock('Illuminate\Database\ConnectionResolverInterface'));
$resolver->shouldReceive('connection')->andReturn($mockConnection = m::mock('Illuminate\Database\ConnectionInterface'));
$mockConnection->shouldreceive('getPostProcessor')->andReturn(m::mock('Illuminate\Database\Query\Processors\Processor'));
$mockConnection->shouldReceive('getQueryGrammar')->andReturn($queryGrammar = m::mock('Illuminate\Database\Query\Grammars\Grammar'));
$queryGrammar->shouldReceive('getDateFormat')->andReturn('Y-m-d H:i:s');
Using sqllite
I will suggest, then, to actually use a sqlite database for testing database connections. I've found this much easier.
Testing with PHPunit triggers the testing environment in Laravel, so you can define an in-memory (only on for that request) sqlite database connection on that environment and and even seed it in your test setup.
Here's a sample gist for testing using an in-memory sqlite database.
Testing things already tested
Your unit test here might be simplistic for example, I'm not sure - However, you're testing something that's already tested in Laravel. Consider carefully what you decide to test :D
Related
I am trying to export my application using the command line utility APEXExport. (APEX 19.2)
Exception in thread "main" java.sql.SQLException: ORA-06550: line 2, column 12:
PLS-00306: wrong number or types of arguments in call to 'GET_APPLICATION'
ORA-06550: line 2, column 5:
PL/SQL: Statement ignored
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:494)
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:446)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1054)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:623)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:252)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:612)
at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:223)
at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:56)
at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:907)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1119)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3780)
at oracle.jdbc.driver.T4CCallableStatement.executeInternal(T4CCallableStatement.java:1300)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3887)
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4230)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1079)
at oracle.apex.APEXExport.exec_and_write_files(APEXExport.java:222)
at oracle.apex.APEXExport.ExportFile(APEXExport.java:523)
at oracle.apex.APEXExport.ExportFiles(APEXExport.java:332)
at oracle.apex.APEXExport.main(APEXExport.java:890)
Caused by: Error : 6550, Position : 17, Sql = begin
:1 := apex_export.get_application (
p_application_id => :2 ,
p_split => :3 ='Y',
p_with_date => :4 ='Y',
p_with_ir_public_reports => :5 ='Y',
p_with_ir_private_reports => :6 ='Y',
p_with_ir_notifications => :7 ='Y',
p_with_translations => :8 ='Y',
p_with_pkg_app_mapping => :9 ='Y',
p_with_original_ids => :10 ='Y',
p_with_no_subscriptions => :11 ='Y',
p_with_comments => :12 ='Y',
p_with_supporting_objects => :13 ,
p_with_acl_assignments => :14 ='Y',
p_components => apex_string.split(:15 ,'#') );
end;, OriginalSql = begin
? := apex_export.get_application (
p_application_id => ?,
p_split => ?='Y',
p_with_date => ?='Y',
p_with_ir_public_reports => ?='Y',
p_with_ir_private_reports => ?='Y',
p_with_ir_notifications => ?='Y',
p_with_translations => ?='Y',
p_with_pkg_app_mapping => ?='Y',
p_with_original_ids => ?='Y',
p_with_no_subscriptions => ?='Y',
p_with_comments => ?='Y',
p_with_supporting_objects => ?,
p_with_acl_assignments => ?='Y',
p_components => apex_string.split(?,'#') );
end;, Error Msg = ORA-06550: line 2, column 12:
PLS-00306: wrong number or types of arguments in call to 'GET_APPLICATION'
ORA-06550: line 2, column 5:
PL/SQL: Statement ignored
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:498)
... 18 more
I ran a fairly staright forward command from cmd
cd <Navigated to utilites folder in apex installation>
%JAVA_HOME%\java oracle.apex.APEXExport -db "myhost:myport:servicename" -user my_user -password my_password -applicationid 120
However, when i use APEX 18.2 installation, application is exported without issues.
Let me know if i am doing it wrong? Or is it a bug in APEX 19.2 (not listed in know issues)
Thanks in advance
Nowadays I would recommend using SQLcl instead of the "old" APEXExport utility...
SQLcl has built in APEX export tools which work nicely and have all the features of the old utility plus some more. Just connect with SQLcl to your DB parsing schema and type "apex export" for a command help page.
https://www.oracle.com/database/technologies/appdev/sqlcl.html
apex export command
Getting this error :
[error] 1118#1118: *366 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught exception 'Predis\Response\ServerException' with message 'MOVED 7369 10.0.213.16:6379'
My Redis connection code is:
$parameters = array(
"scheme" => "tcp",
"host" => "testingredis.akf46e.clustercfg.use1.cache.amazonaws.com",
"port" => 6379,
"database" => 0,
);
$db = new Predis\Client($parameters, $options);
Note: The above code is working fine in local but not working in my AWS server. Any help would be appreciated.
After lots of research successfully completed the redis cluster with the AWS elasticache.
$options = array('cluster' => 'redis');
$parameters = array(
'clusters' => array(
'default' => array(
'scheme' => 'tcp',
'host' => HOST_URL,
'port' => 6379,
'database' => 0
),
),
);
$db = new Predis\Client($parameters,$options);
Were struggling with same. this is short version of what works:
$redis = new Predis\Client(
['tcp://127.0.0.1:6379'],
['cluster' => 'redis']
);
Following code works well in PHP 5.6.
require_once '../aws/aws-autoloader.php';
$config = [
'region' => 'ap-south-1',
'version' => 'latest',
'credentials' => [
'key' => '...',
'secret' => '...'
]
];
$sdk = new Aws\Sdk($config);
$client = $sdk->createS3();
But on PHP 7, it through error:
Fatal error: Uncaught TypeError: Argument 1 passed to Aws\Common\Client\AbstractClient::__construct() must be an instance of Aws\Common\Credentials\CredentialsInterface, array given, called in /var/www/html/webservice/vendor/aws3/Aws/Sdk.php on line 316 and defined in /var/www/html/aws-sdk/vendor/aws/aws-sdk-php/src/Aws/Common/Client/AbstractClient.php:75 Stack trace: #0 /var/www/html/webservice/vendor/aws3/Aws/Sdk.php(316): Aws\Common\Client\AbstractClient->__construct(Array) #1 /var/www/html/webservice/vendor/aws3/Aws/Sdk.php(291): Aws\Sdk->createClient('S3', Array) #2 index.php(14): Aws\Sdk->__call('createS3', Array) thrown in /var/www/html/aws-sdk/vendor/aws/aws-sdk-php/src/Aws/Common/Client/AbstractClient.php on line 75
Please suggest me how can I make it work on PHP 7.
Thanks.
UPDATE: I have both AWS SDK version 2 & 3 in my project. this might be a issue of conflict. Then how to solve the conflict?
This problem doesn't have any issue with PHP 7.0.
It's the case of conflict SDK ver 2 & 3.
This two sdk can't be used together. so I had to upgrade to sdk 3.
I have been using Doctrine and Migrations in my ZF2 project for a few weeks without issue. I have been executing migrations by specifying my own configuration file:
vendor/bin/doctrine-module migrations:diff --configuration=/path/to/migrations-config.xml
I recently brought in Codeception into my project via composer and when I recently went to execute a new migration (with the same above command), I received the following error:
[InvalidArgumentException]
Migrations directory data/DoctrineORMModule/Migrations does not exist
This is not the directory I have specified in my configuration file. At first I thought Doctrine Migrations was completely ignoring my --configuration argument. When I traced it through, I saw that Doctrine Migrations wasn't using my --configuration argument because it had already loaded a config file.
Would anyone know where this config file may be pulling in from? I can work around the issue for the time being by commenting out the conditional in AbstractCommand getMigrationConfiguration(), but long term I'd rather not have to rely on this. I'll also try and remove codeception and see if that has any impact. Any help is appreciated.
As it turns out, I was able to move Doctrine migrations configuration into my ZF2 module config. In my module.config.php, I have the following specified (Api is the module name):
'doctrine' => array(
'driver' => array(
'application_entities' => array(
'class' =>'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(__DIR__ . '/../src/Api/Entity')
),
'orm_default' => array(
'drivers' => array(
'Api\Entity' => 'application_entities'
)
)
),
'migrations_configuration' => array(
'orm_default' => array(
'directory' => 'data/migrations',
'namespace' => 'My\Namespace\Migrations',
'table' => 'migrations',
),
),
),
This allows me to run Doctrine migrations commands without having to specify a configuration file, for example:
vendor/bin/doctrine-module migrations:diff
I see an alternative in using a stand-alone doctrine-migration.phar command:
php doctrine-migrations.phar migrations:migrate --configuration=config.xml --db-configuration=db-config.xml
To make this work, you need to download doctrine-migrations.phar from here: https://github.com/doctrine/migrations
I've just started with Zend framework 2, with Doctrine. I want to set up unit testing for my Album module.
When I run c:\wamp\www\zf2-tutorial\module\Album\test > phpunit from command prompt,
I get following error:
PHPUnit 3.7.10 by Sebastian Bergmann.
Configuration read from C:\wamp\www\zf2-tutorial\module\Album\test\phpunit.xml.d
ist
.FFE
Time: 2 seconds, Memory: 8.25Mb
There was 1 error:
1) AlbumTest\Controller\AlbumControllerTest::testIndexActionCanBeAccessed
Zend\ServiceManager\Exception\ServiceNotFoundException: Zend\ServiceManager\Serv
iceManager::get was unable to fetch or create an instance for doctrine.entityman
ager.orm_default
C:\wamp\www\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Service
Manager\ServiceManager.php:452
C:\wamp\www\zf2-tutorial\module\Album\src\Album\Controller\AlbumController.php:2
5
C:\wamp\www\zf2-tutorial\module\Album\src\Album\Controller\AlbumController.php:3
3
C:\wamp\www\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Mvc\Con
troller\AbstractActionController.php:88
C:\wamp\www\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\EventMa
nager\EventManager.php:464
C:\wamp\www\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\EventMa
nager\EventManager.php:208
C:\wamp\www\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Mvc\Con
troller\AbstractController.php:107
C:\wamp\www\zf2-tutorial\module\Album\test\AlbumTest\Controller\AlbumControllerT
est.php:71
--
There were 2 failures:
1) AlbumTest\Controller\AlbumControllerTest::testDeleteActionCanBeAccessed
Failed asserting that 302 matches expected 200.
C:\wamp\www\zf2-tutorial\module\Album\test\AlbumTest\Controller\AlbumControllerT
est.php:54
2) AlbumTest\Controller\AlbumControllerTest::testEditActionCanBeAccessed
Failed asserting that 302 matches expected 200.
C:\wamp\www\zf2-tutorial\module\Album\test\AlbumTest\Controller\AlbumControllerT
est.php:64
FAILURES!
Tests: 4, Assertions: 3, Failures: 2, Errors: 1.
The root of the issue seems to be:
Zend\ServiceManager\Exception\ServiceNotFoundException: Zend\ServiceManager\Serv
iceManager::get was unable to fetch or create an instance for doctrine.entityman
ager.orm_default from test..
I don't understand this, please help!
Okay finally got it!!
I changed my TestConfig.php.dist inside module/Album/test to
<?php
return array(
'modules' => array(
'DoctrineModule',
'DoctrineORMModule',
'Album',
),
'module_listener_options' => array(
'config_glob_paths' => array(
'../../../config/autoload/{,*.}{global,local}.php',
),
'module_paths' => array(
'module',
'vendor',
),
),
);
so basically just added two missing modules, DoctrineModule and DoctrineORMModule, and the phpunit command showed no errors!
Hope it helps others.