Skip to content

Commit

Permalink
Merge 8d45c21 into 50a8c3f
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Jul 22, 2020
2 parents 50a8c3f + 8d45c21 commit 16e72a7
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* @mixin \Search\Model\Behavior\SearchBehavior
*/
class GroupsTable extends Table
class SectionsTable extends Table
{
public function initialize(array $config): void
{
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/Controller/Component/SearchComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ class SearchComponentTest extends TestCase
/**
* @var array
*/
public $fixtures = [
protected $fixtures = [
'plugin.Search.Articles',
];

/**
* @var \Cake\Controller\Controller
*/
public $Controller;
protected $Controller;

/**
* @var \Search\Controller\Component\SearchComponent
*/
public $Search;
protected $Search;

/**
* @return void
Expand Down
27 changes: 13 additions & 14 deletions tests/TestCase/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
namespace Search\Test\TestCase;

use Cake\Core\Configure;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
use InvalidArgumentException;
use Search\Manager;
Expand All @@ -16,7 +15,7 @@ class ManagerTest extends TestCase
*
* @var array
*/
public $fixtures = [
protected $fixtures = [
'plugin.Search.Articles',
];

Expand All @@ -25,7 +24,7 @@ class ManagerTest extends TestCase
*/
public function testShorthandMethods()
{
$table = TableRegistry::get('Articles');
$table = $this->getTableLocator()->get('Articles');

$options = ['foo' => 'bar'];

Expand Down Expand Up @@ -65,7 +64,7 @@ public function testMagicShorthandMethods()
{
Configure::write('App.namespace', 'Search\Test\TestApp');

$table = TableRegistry::get('Articles');
$table = $this->getTableLocator()->get('Articles');

$manager = new Manager($table);
$manager->testFilter('test1');
Expand All @@ -86,7 +85,7 @@ public function testMagicShorthandMethods()
*/
public function testAll()
{
$table = TableRegistry::get('Articles');
$table = $this->getTableLocator()->get('Articles');
$manager = new Manager($table);

$this->assertEmpty(iterator_to_array($manager->getFilters()));
Expand All @@ -107,7 +106,7 @@ public function testAll()
*/
public function testAdd()
{
$table = TableRegistry::get('Articles');
$table = $this->getTableLocator()->get('Articles');
$manager = new Manager($table);
$manager->add('testOne', 'Search.Value');
$manager->add('testTwo', 'Search.Compare');
Expand All @@ -123,7 +122,7 @@ public function testAdd()
*/
public function testGetFilters()
{
$table = TableRegistry::get('Articles');
$table = $this->getTableLocator()->get('Articles');
$manager = new Manager($table);
$manager->add('test', 'Search.Value');
$manager->add('test2', 'Search.Compare');
Expand All @@ -147,7 +146,7 @@ public function testGetFiltersNonExistentCollection()
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The collection class "NonExistentCollection" does not exist');

$table = TableRegistry::get('Articles');
$table = $this->getTableLocator()->get('Articles');
$manager = new Manager($table);
$manager->getFilters('non_existent');
}
Expand All @@ -157,7 +156,7 @@ public function testGetFiltersNonExistentCollection()
*/
public function testRemove()
{
$table = TableRegistry::get('Articles');
$table = $this->getTableLocator()->get('Articles');
$manager = new Manager($table);

$manager->add('test', 'Search.Value');
Expand All @@ -179,7 +178,7 @@ public function testRemove()
*/
public function testRepository()
{
$table = TableRegistry::get('Articles');
$table = $this->getTableLocator()->get('Articles');
$manager = new Manager($table);
$result = $manager->getRepository();
$this->assertInstanceOf('\Cake\Datasource\RepositoryInterface', $result);
Expand All @@ -190,7 +189,7 @@ public function testRepository()
*/
public function testTable()
{
$table = TableRegistry::get('Articles');
$table = $this->getTableLocator()->get('Articles');
$manager = new Manager($table);
$result = $manager->getRepository();
$this->assertInstanceOf('\Cake\Datasource\RepositoryInterface', $result);
Expand All @@ -201,7 +200,7 @@ public function testTable()
*/
public function testCollection()
{
$table = TableRegistry::get('Articles');
$table = $this->getTableLocator()->get('Articles');
$manager = new Manager($table);

$result = $manager->getCollectionName();
Expand Down Expand Up @@ -232,7 +231,7 @@ public function testCollection()
*/
public function testCollectionCombined()
{
$table = TableRegistry::get('Articles');
$table = $this->getTableLocator()->get('Articles');
$manager = new Manager($table);

$result = $manager->getCollectionName();
Expand All @@ -247,7 +246,7 @@ public function testCollectionCombined()
*/
public function testInvalidCollectionClass()
{
$table = TableRegistry::get('Articles');
$table = $this->getTableLocator()->get('Articles');
$manager = new Manager($table, Configure::class);

$this->expectException(InvalidArgumentException::class);
Expand Down
27 changes: 13 additions & 14 deletions tests/TestCase/Model/Behavior/SearchBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

namespace Search\Test\TestCase\Model\Behavior;

use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
use Search\Manager;
use Search\Model\Filter\FilterCollection;
Expand All @@ -13,27 +12,27 @@ class SearchBehaviorTest extends TestCase
/**
* @var \Search\Test\TestApp\Model\Table\ArticlesTable
*/
public $Articles;
protected $Articles;

/**
* @var \Search\Test\TestApp\Model\Table\CommentsTable
*/
public $Comments;
protected $Comments;

/**
* @var \Search\Test\TestApp\Model\Table\GroupsTable
* @var \Search\Test\TestApp\Model\Table\SectionsTable
*/
public $Groups;
protected $Sections;

/**
* Fixtures
*
* @var array
*/
public $fixtures = [
protected $fixtures = [
'plugin.Search.Articles',
'core.Comments',
'core.Groups',
'core.Sections',
];

/**
Expand All @@ -45,19 +44,19 @@ public function setUp(): void
{
parent::setUp();

TableRegistry::clear();
$this->Articles = TableRegistry::get('Articles', [
$this->getTableLocator()->clear();
$this->Articles = $this->getTableLocator()->get('Articles', [
'className' => 'Search\Test\TestApp\Model\Table\ArticlesTable',
]);
$this->Articles->addBehavior('Search.Search');
$this->Comments = TableRegistry::get('Comments', [
$this->Comments = $this->getTableLocator()->get('Comments', [
'className' => 'Search\Test\TestApp\Model\Table\CommentsTable',
]);
$this->Comments->addBehavior('Search.Search');
$this->Groups = TableRegistry::get('Groups', [
'className' => 'Search\Test\TestApp\Model\Table\GroupsTable',
$this->Sections = $this->getTableLocator()->get('Sections', [
'className' => 'Search\Test\TestApp\Model\Table\SectionsTable',
]);
$this->Groups->addBehavior('Search.Search');
$this->Sections->addBehavior('Search.Search');
}

/**
Expand Down Expand Up @@ -299,7 +298,7 @@ public function testAliasedFinder()
*/
public function testCollectionFinder($collection, $queryString, $expected)
{
$query = $this->Groups->find('search', ['search' => $queryString, 'collection' => $collection]);
$query = $this->Sections->find('search', ['search' => $queryString, 'collection' => $collection]);
$this->assertEquals($expected, $query->count());
}

Expand Down
7 changes: 3 additions & 4 deletions tests/TestCase/Model/Filter/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
namespace Search\Test\TestCase\Model\Filter;

use Cake\Datasource\RepositoryInterface;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
use Search\Manager;
use Search\Test\TestApp\Model\Filter\TestFilter;
Expand All @@ -14,14 +13,14 @@ class BaseTest extends TestCase
/**
* @var \Search\Manager
*/
public $Manager;
protected $Manager;

/**
* Fixtures
*
* @var array
*/
public $fixtures = [
protected $fixtures = [
'plugin.Search.Articles',
];

Expand All @@ -32,7 +31,7 @@ class BaseTest extends TestCase
*/
public function setUp(): void
{
$table = TableRegistry::get('Articles');
$table = $this->getTableLocator()->get('Articles');
$this->Manager = new Manager($table);
}

Expand Down
Loading

0 comments on commit 16e72a7

Please sign in to comment.