mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 14:05:29 +02:00
Merge pull request #219 from creative-commoners/pulls/3.3/travis-recipes
Add different core installer versions to Travis matrix and add own phpcs ruleset
This commit is contained in:
commit
393377c8f8
15
.travis.yml
15
.travis.yml
@ -7,31 +7,32 @@ env:
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- php: 5.6
|
- php: 5.6
|
||||||
env: DB=MYSQL PHPCS_TEST=1 PHPUNIT_TEST=1
|
env: DB=MYSQL INSTALLER_VERSION=4.0.x-dev PHPCS_TEST=1 PHPUNIT_TEST=1
|
||||||
- php: 7.0
|
- php: 7.0
|
||||||
env: DB=PGSQL PHPUNIT_TEST=1
|
env: DB=PGSQL INSTALLER_VERSION=4.1.x-dev PHPUNIT_TEST=1
|
||||||
- php: 7.1
|
- php: 7.1
|
||||||
env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1
|
env: DB=MYSQL INSTALLER_VERSION=4.1.x-dev PHPUNIT_COVERAGE_TEST=1
|
||||||
- php: 7.1
|
- php: 7.1
|
||||||
env: DB=MYSQL PHPUNIT_TEST=1 SUBSITES=1
|
env: DB=MYSQL INSTALLER_VERSION=4.2.x-dev PHPUNIT_TEST=1 SUBSITES=1
|
||||||
- php: 7.2
|
- php: 7.2
|
||||||
env: DB=MYSQL PHPUNIT_TEST=1
|
env: DB=MYSQL INSTALLER_VERSION=4.x-dev PHPUNIT_TEST=1
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- phpenv rehash
|
- phpenv rehash
|
||||||
- phpenv config-rm xdebug.ini
|
- phpenv config-rm xdebug.ini
|
||||||
|
- echo 'memory_limit=2G' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
|
||||||
|
|
||||||
- composer validate
|
- composer validate
|
||||||
- composer require --no-update symbiote/silverstripe-queuedjobs ^4.0
|
- composer require --no-update symbiote/silverstripe-queuedjobs ^4.0
|
||||||
- if [[ $SUBSITES ]]; then composer require --no-update silverstripe/subsites 2.0.x-dev; fi
|
- if [[ $SUBSITES ]]; then composer require --no-update silverstripe/subsites 2.0.x-dev; fi
|
||||||
- if [[ $DB == "PGSQL" ]]; then composer require --no-update silverstripe/postgresql 2.0.x-dev; fi
|
- if [[ $DB == "PGSQL" ]]; then composer require --no-update silverstripe/postgresql 2.0.x-dev; fi
|
||||||
- composer require --no-update silverstripe/installer 4.0.x-dev
|
- composer require --no-update silverstripe/installer "$INSTALLER_VERSION"
|
||||||
- composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile
|
- composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit; fi
|
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit; fi
|
||||||
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi
|
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi
|
||||||
- if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs --standard=vendor/silverstripe/framework/phpcs.xml.dist src tests; fi
|
- if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs src tests; fi
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi
|
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi
|
||||||
|
14
phpcs.xml.dist
Normal file
14
phpcs.xml.dist
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ruleset name="SilverStripe">
|
||||||
|
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>
|
||||||
|
|
||||||
|
<!-- base rules are PSR-2 -->
|
||||||
|
<rule ref="PSR2">
|
||||||
|
<!-- Current exclusions -->
|
||||||
|
<exclude name="PSR1.Methods.CamelCapsMethodName"/>
|
||||||
|
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols"/>
|
||||||
|
<exclude name="PSR2.Methods.MethodDeclaration.Underscore"/>
|
||||||
|
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>
|
||||||
|
<exclude name="Generic.Files.LineLength.TooLong"/>
|
||||||
|
</rule>
|
||||||
|
</ruleset>
|
@ -5,23 +5,19 @@ namespace SilverStripe\FullTextSearch\Tests;
|
|||||||
use SilverStripe\Core\Config\Config;
|
use SilverStripe\Core\Config\Config;
|
||||||
use SilverStripe\Core\Injector\Injector;
|
use SilverStripe\Core\Injector\Injector;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\FullTextSearch\Solr\Services\SolrService;
|
|
||||||
use SilverStripe\ORM\DataObject;
|
|
||||||
use SilverStripe\ORM\DB;
|
|
||||||
use SilverStripe\FullTextSearch\Search\FullTextSearch;
|
use SilverStripe\FullTextSearch\Search\FullTextSearch;
|
||||||
use SilverStripe\FullTextSearch\Search\Updaters\SearchUpdater;
|
|
||||||
use SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexQueuedHandler;
|
|
||||||
use SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler;
|
use SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler;
|
||||||
use SilverStripe\FullTextSearch\Solr\Services\Solr4Service;
|
use SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexQueuedHandler;
|
||||||
use SilverStripe\FullTextSearch\Solr\Reindex\Jobs\SolrReindexQueuedJob;
|
|
||||||
use SilverStripe\FullTextSearch\Solr\Reindex\Jobs\SolrReindexGroupQueuedJob;
|
use SilverStripe\FullTextSearch\Solr\Reindex\Jobs\SolrReindexGroupQueuedJob;
|
||||||
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_Variant;
|
use SilverStripe\FullTextSearch\Solr\Reindex\Jobs\SolrReindexQueuedJob;
|
||||||
|
use SilverStripe\FullTextSearch\Solr\Services\Solr4Service;
|
||||||
|
use SilverStripe\FullTextSearch\Solr\Services\SolrService;
|
||||||
|
use SilverStripe\FullTextSearch\Tests\SolrReindexQueuedTest\SolrReindexQueuedTest_Service;
|
||||||
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_Index;
|
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_Index;
|
||||||
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_Item;
|
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_Item;
|
||||||
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_RecordingLogger;
|
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_RecordingLogger;
|
||||||
use SilverStripe\FullTextSearch\Tests\SolrReindexQueuedTest\SolrReindexQueuedTest_Service;
|
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_Variant;
|
||||||
use Symbiote\QueuedJobs\Services\QueuedJob;
|
use Symbiote\QueuedJobs\Services\QueuedJob;
|
||||||
use Symbiote\QueuedJobs\Services\QueuedJobService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Additional tests of solr reindexing processes when run with queuedjobs
|
* Additional tests of solr reindexing processes when run with queuedjobs
|
||||||
@ -80,13 +76,9 @@ class SolrReindexQueuedTest extends SapphireTest
|
|||||||
*/
|
*/
|
||||||
protected function createDummyData($number)
|
protected function createDummyData($number)
|
||||||
{
|
{
|
||||||
// Populate dataobjects. Use truncate to generate predictable IDs
|
|
||||||
$tableName = DataObject::getSchema()->tableName(SolrReindexTest_Item::class);
|
|
||||||
DB::get_conn()->clearTable($tableName);
|
|
||||||
|
|
||||||
// Note that we don't create any records in variant = 2, to represent a variant
|
// Note that we don't create any records in variant = 2, to represent a variant
|
||||||
// that should be cleared without any re-indexes performed
|
// that should be cleared without any re-indexes performed
|
||||||
foreach (array(0, 1) as $variant) {
|
foreach ([0, 1] as $variant) {
|
||||||
for ($i = 1; $i <= $number; $i++) {
|
for ($i = 1; $i <= $number; $i++) {
|
||||||
$item = new SolrReindexTest_Item();
|
$item = new SolrReindexTest_Item();
|
||||||
$item->Variant = $variant;
|
$item->Variant = $variant;
|
||||||
@ -104,7 +96,7 @@ class SolrReindexQueuedTest extends SapphireTest
|
|||||||
protected function serviceMock()
|
protected function serviceMock()
|
||||||
{
|
{
|
||||||
// Setup mock
|
// Setup mock
|
||||||
/** @var SilverStripe\FullTextSearch\Solr\Services\Solr4Service|ObjectProphecy $serviceMock */
|
/** @var Solr4Service $serviceMock */
|
||||||
$serviceMock = $this->getMockBuilder(Solr4Service::class)
|
$serviceMock = $this->getMockBuilder(Solr4Service::class)
|
||||||
->setMethods(['deleteByQuery', 'addDocument'])
|
->setMethods(['deleteByQuery', 'addDocument'])
|
||||||
->getMock();
|
->getMock();
|
||||||
@ -112,7 +104,7 @@ class SolrReindexQueuedTest extends SapphireTest
|
|||||||
return $serviceMock;
|
return $serviceMock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
protected function tearDown()
|
||||||
{
|
{
|
||||||
FullTextSearch::force_index_list();
|
FullTextSearch::force_index_list();
|
||||||
SolrReindexTest_Variant::disable();
|
SolrReindexTest_Variant::disable();
|
||||||
@ -212,6 +204,7 @@ class SolrReindexQueuedTest extends SapphireTest
|
|||||||
$this->assertEquals(6, $logger->countMessages('Queued Solr Reindex Group'));
|
$this->assertEquals(6, $logger->countMessages('Queued Solr Reindex Group'));
|
||||||
|
|
||||||
// Check next job is a group queued job
|
// Check next job is a group queued job
|
||||||
|
/** @var SolrReindexGroupQueuedJob $job */
|
||||||
$job = $this->getQueuedJobService()->getNextJob();
|
$job = $this->getQueuedJobService()->getNextJob();
|
||||||
$this->assertInstanceOf(SolrReindexGroupQueuedJob::class, $job);
|
$this->assertInstanceOf(SolrReindexGroupQueuedJob::class, $job);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
namespace SilverStripe\FullTextSearch\Tests\SolrReindexQueuedTest;
|
namespace SilverStripe\FullTextSearch\Tests\SolrReindexQueuedTest;
|
||||||
|
|
||||||
use SilverStripe\Dev\TestOnly;
|
use SilverStripe\Dev\TestOnly;
|
||||||
|
use Symbiote\QueuedJobs\Services\QueuedJob;
|
||||||
|
use Symbiote\QueuedJobs\Services\QueuedJobService;
|
||||||
|
|
||||||
if (!class_exists('Symbiote\QueuedJobs\Services\QueuedJobService')) {
|
if (!class_exists(QueuedJobService::class)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
use Symbiote\QueuedJobs\Services\QueuedJobService;
|
|
||||||
|
|
||||||
class SolrReindexQueuedTest_Service extends QueuedJobService implements TestOnly
|
class SolrReindexQueuedTest_Service extends QueuedJobService implements TestOnly
|
||||||
{
|
{
|
||||||
private static $dependencies = [
|
private static $dependencies = [
|
||||||
|
@ -2,22 +2,20 @@
|
|||||||
|
|
||||||
namespace SilverStripe\FullTextSearch\Tests;
|
namespace SilverStripe\FullTextSearch\Tests;
|
||||||
|
|
||||||
use SilverStripe\Dev\SapphireTest;
|
|
||||||
use SilverStripe\FullTextSearch\Search\FullTextSearch;
|
|
||||||
use SilverStripe\FullTextSearch\Search\Updaters\SearchUpdater;
|
|
||||||
use SilverStripe\FullTextSearch\Search\Variants\SearchVariant;
|
|
||||||
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_Variant;
|
|
||||||
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_Index;
|
|
||||||
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_TestHandler;
|
|
||||||
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_Item;
|
|
||||||
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_RecordingLogger;
|
|
||||||
use SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler;
|
|
||||||
use SilverStripe\FullTextSearch\Solr\Services\Solr4Service;
|
|
||||||
use SilverStripe\FullTextSearch\Solr\Tasks\Solr_Reindex;
|
|
||||||
use SilverStripe\Core\Config\Config;
|
use SilverStripe\Core\Config\Config;
|
||||||
use SilverStripe\Core\Injector\Injector;
|
use SilverStripe\Core\Injector\Injector;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\FullTextSearch\Search\FullTextSearch;
|
||||||
|
use SilverStripe\FullTextSearch\Search\Variants\SearchVariant;
|
||||||
|
use SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler;
|
||||||
|
use SilverStripe\FullTextSearch\Solr\Services\Solr4Service;
|
||||||
|
use SilverStripe\FullTextSearch\Solr\Services\SolrService;
|
||||||
|
use SilverStripe\FullTextSearch\Solr\Tasks\Solr_Reindex;
|
||||||
|
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_Index;
|
||||||
|
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_Item;
|
||||||
|
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_RecordingLogger;
|
||||||
|
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_TestHandler;
|
||||||
|
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_Variant;
|
||||||
|
|
||||||
class SolrReindexTest extends SapphireTest
|
class SolrReindexTest extends SapphireTest
|
||||||
{
|
{
|
||||||
@ -70,11 +68,9 @@ class SolrReindexTest extends SapphireTest
|
|||||||
*/
|
*/
|
||||||
protected function createDummyData($number)
|
protected function createDummyData($number)
|
||||||
{
|
{
|
||||||
self::resetDBSchema();
|
|
||||||
|
|
||||||
// Note that we don't create any records in variant = 2, to represent a variant
|
// Note that we don't create any records in variant = 2, to represent a variant
|
||||||
// that should be cleared without any re-indexes performed
|
// that should be cleared without any re-indexes performed
|
||||||
foreach (array(0, 1) as $variant) {
|
foreach ([0, 1] as $variant) {
|
||||||
for ($i = 1; $i <= $number; $i++) {
|
for ($i = 1; $i <= $number; $i++) {
|
||||||
$item = new SolrReindexTest_Item();
|
$item = new SolrReindexTest_Item();
|
||||||
$item->Variant = $variant;
|
$item->Variant = $variant;
|
||||||
@ -97,7 +93,7 @@ class SolrReindexTest extends SapphireTest
|
|||||||
return $serviceMock->getMock();
|
return $serviceMock->getMock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
protected function tearDown()
|
||||||
{
|
{
|
||||||
FullTextSearch::force_index_list();
|
FullTextSearch::force_index_list();
|
||||||
SolrReindexTest_Variant::disable();
|
SolrReindexTest_Variant::disable();
|
||||||
|
Loading…
Reference in New Issue
Block a user