Call to undefined method Cake\Database\Connection::getIndex()
ddgreen opened this issue · 5 comments
ddgreen commented
version:2.0-RC1
I received this Exception message when I ran PHPUnit.
throw point:
$esIndex = $db->getIndex($this->getIndex()->getName());
TestFixture.php, line 129
what is class that this $db
?
(I think Elastica\Index
)
How is this problem solved?
josbeir commented
- Please use 2.0-RC2
- Have you set up your connection correctly ? See here and confirmed that it is working?
ddgreen commented
Thank you.
I installed 2.0-RC2.
And, ElasticSearch correctly work except when I ran PHPUnit.
I think TestFixture
class cause this problem.
My TestCase has app.articles
and app.users
fixture.
app.articles
inheritCake\ElasticSearch\TestSuite\TestFixture
.app.users
inheritCake\TestSuite\Fixture\TestFixture
.
PHPUnit correctly work when I commented out app.articles
.
Should I separete these TestFixture?
ddgreen commented
My app.php :
'elastic' => [
'className' => 'Cake\ElasticSearch\Datasource\Connection',
'driver' => 'Cake\ElasticSearch\Datasource\Connection',
'host' => '127.0.0.1',
'port' => 9200,
],
'test_elastic' => [
'className' => 'Cake\ElasticSearch\Datasource\Connection',
'driver' => 'Cake\ElasticSearch\Datasource\Connection',
'host' => '127.0.0.1',
'port' => 9200,
],
josbeir commented
Have you defined the correct connection name in your articles fixture ?
class ArticlesFixture extends TestFixture
{
/**
* Table/Index name
*
* @var string
*/
public $table = 'Articles';
/*
* Set the elastic connection
*
* @var string
*/
public $connection = 'test_elastic';
ddgreen commented
public $connection = 'test_elastic';
PHPUnit correctly worked after I added this line!
Thank you, josbeir!