mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-21 23:16:10 +01:00
FEATURE: Setup first working functional test
This commit is contained in:
parent
e75f24092e
commit
a7714945c6
6 changed files with 237 additions and 7 deletions
29
Makefile
29
Makefile
|
@ -3,18 +3,33 @@ current_dir := $(dir $(mkfile_path))
|
|||
|
||||
TYPO3_WEB_DIR := $(current_dir).Build/Web
|
||||
# Allow different versions on travis
|
||||
TYPO3_VERSION ?= ~6.2
|
||||
TYPO3_VERSION ?= ~6.2.19
|
||||
typo3DatabaseName ?= "test"
|
||||
typo3DatabaseUsername ?= "dev"
|
||||
typo3DatabasePassword ?= "dev"
|
||||
typo3DatabaseHost ?= "127.0.0.1"
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
rm -rf .Build
|
||||
|
||||
composer require --dev --prefer-source typo3/cms="$(TYPO3_VERSION)"
|
||||
composer update -vv
|
||||
rm .Build
|
||||
COMPOSER_PROCESS_TIMEOUT=1000 composer require -vvv --dev typo3/cms="$(TYPO3_VERSION)"
|
||||
|
||||
git checkout composer.json
|
||||
mkdir -p $(TYPO3_WEB_DIR)/uploads $(TYPO3_WEB_DIR)/typo3temp
|
||||
|
||||
unitTests:
|
||||
TYPO3_PATH_WEB=$(TYPO3_WEB_DIR) \
|
||||
.Build/bin/phpunit --colors --debug -v \
|
||||
-c Tests/Unit/UnitTests.xml
|
||||
|
||||
functionalTests:
|
||||
typo3DatabaseName=$(typo3DatabaseName) \
|
||||
typo3DatabaseUsername=$(typo3DatabaseUsername) \
|
||||
typo3DatabasePassword=$(typo3DatabasePassword) \
|
||||
typo3DatabaseHost=$(typo3DatabaseHost) \
|
||||
TYPO3_PATH_WEB=$(TYPO3_WEB_DIR) \
|
||||
.Build/bin/phpunit --colors --debug -v \
|
||||
-c Tests/Functional/FunctionalTests.xml
|
||||
|
||||
.PHONY: Tests
|
||||
Tests:
|
||||
TYPO3_PATH_WEB=$(TYPO3_WEB_DIR) .Build/bin/phpunit --colors --debug -v -c Tests/Unit/UnitTests.xml
|
||||
Tests: unitTests functionalTests
|
||||
|
|
12
Tests/Functional/Fixtures/Indexing/IndexTcaTable.ts
Normal file
12
Tests/Functional/Fixtures/Indexing/IndexTcaTable.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
plugin {
|
||||
tx_searchcore {
|
||||
settings {
|
||||
connection {
|
||||
host = localhost
|
||||
port = 9200
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.tx_searchcore < plugin.tx_searchcore
|
69
Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml
Normal file
69
Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml
Normal file
|
@ -0,0 +1,69 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<dataset>
|
||||
<pages>
|
||||
<uid>1</uid>
|
||||
<pid>0</pid>
|
||||
<title>Page Title</title>
|
||||
</pages>
|
||||
|
||||
<tt_content>
|
||||
<uid>6</uid>
|
||||
<pid>1</pid>
|
||||
<tstamp>1480686370</tstamp>
|
||||
<crdate>1480686370</crdate>
|
||||
<hidden>0</hidden>
|
||||
<sorting>72</sorting>
|
||||
<CType>textmedia</CType>
|
||||
<header>test</header>
|
||||
<bodytext>this is the content of textmedia content element that should get indexed</bodytext>
|
||||
<media>0</media>
|
||||
<layout>0</layout>
|
||||
<deleted>0</deleted>
|
||||
<cols>0</cols>
|
||||
<starttime>0</starttime>
|
||||
<endtime>0</endtime>
|
||||
<colPos>0</colPos>
|
||||
<filelink_sorting>0</filelink_sorting>
|
||||
</tt_content>
|
||||
|
||||
<tt_content>
|
||||
<uid>7</uid>
|
||||
<pid>1</pid>
|
||||
<tstamp>1480686371</tstamp>
|
||||
<crdate>1480686370</crdate>
|
||||
<hidden>0</hidden>
|
||||
<sorting>72</sorting>
|
||||
<CType>textmedia</CType>
|
||||
<header>endtime hidden record</header>
|
||||
<bodytext></bodytext>
|
||||
<media>0</media>
|
||||
<layout>0</layout>
|
||||
<deleted>0</deleted>
|
||||
<cols>0</cols>
|
||||
<starttime>0</starttime>
|
||||
<endtime>1481305963</endtime>
|
||||
<colPos>0</colPos>
|
||||
<filelink_sorting>0</filelink_sorting>
|
||||
</tt_content>
|
||||
|
||||
<tt_content>
|
||||
<uid>8</uid>
|
||||
<pid>1</pid>
|
||||
<tstamp>1480686370</tstamp>
|
||||
<crdate>1480686370</crdate>
|
||||
<hidden>1</hidden>
|
||||
<sorting>72</sorting>
|
||||
<CType>textmedia</CType>
|
||||
<header>Hidden record</header>
|
||||
<bodytext></bodytext>
|
||||
<media>0</media>
|
||||
<layout>0</layout>
|
||||
<deleted>0</deleted>
|
||||
<cols>0</cols>
|
||||
<starttime>0</starttime>
|
||||
<endtime>0</endtime>
|
||||
<colPos>0</colPos>
|
||||
<filelink_sorting>0</filelink_sorting>
|
||||
</tt_content>
|
||||
|
||||
</dataset>
|
56
Tests/Functional/FunctionalTestCase.php
Normal file
56
Tests/Functional/FunctionalTestCase.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
namespace Leonmrni\SearchCore\Tests\Functional;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2016 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\Tests\FunctionalTestCase as CoreTestCase;
|
||||
|
||||
/**
|
||||
* All functional tests should extend this base class.
|
||||
*
|
||||
* It will take care of leaving a clean environment for next test.
|
||||
*/
|
||||
abstract class FunctionalTestCase extends CoreTestCase
|
||||
{
|
||||
protected $testExtensionsToLoad = ['typo3conf/ext/search_core'];
|
||||
|
||||
/**
|
||||
* @var \Elastica\Client
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// Create client to make requests and assert something.
|
||||
$this->client = new \Elastica\Client([
|
||||
'host' => getenv('ES_HOST') ?: \Elastica\Connection::DEFAULT_HOST,
|
||||
'port' => getenv('ES_PORT') ?: \Elastica\Connection::DEFAULT_PORT,
|
||||
]);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
// Delete everything so next test starts clean.
|
||||
$this->client->getIndex('_all')->delete();
|
||||
$this->client->getIndex('_all')->clearCache();
|
||||
}
|
||||
}
|
22
Tests/Functional/FunctionalTests.xml
Normal file
22
Tests/Functional/FunctionalTests.xml
Normal file
|
@ -0,0 +1,22 @@
|
|||
<phpunit
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="../../.Build/vendor/typo3/cms/typo3/sysext/core/Build/FunctionalTestsBootstrap.php"
|
||||
|
||||
colors="true"
|
||||
convertErrorsToExceptions="false"
|
||||
convertWarningsToExceptions="false"
|
||||
forceCoversAnnotation="false"
|
||||
processIsolation="false"
|
||||
stopOnError="false"
|
||||
stopOnFailure="false"
|
||||
stopOnIncomplete="false"
|
||||
stopOnSkipped="false"
|
||||
verbose="false">
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="functional-tests">
|
||||
<directory>.</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
56
Tests/Functional/Indexing/IndexTcaTableTest.php
Normal file
56
Tests/Functional/Indexing/IndexTcaTableTest.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
namespace Leonmrni\SearchCore\Tests\Functional\Indexing;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2016 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use Leonmrni\SearchCore\Domain\Index\IndexerFactory;
|
||||
use Leonmrni\SearchCore\Tests\Functional\FunctionalTestCase;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class IndexTcaTableTest extends FunctionalTestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->importDataSet('Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml');
|
||||
$this->setUpFrontendRootPage(1, ['EXT:search_core/Tests/Functional/Fixtures/Indexing/IndexTcaTable.ts']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function indexBasicTtContentWithoutBasicConfiguration()
|
||||
{
|
||||
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class)
|
||||
->get(IndexerFactory::class)
|
||||
->getIndexer('tt_content')
|
||||
->index()
|
||||
;
|
||||
|
||||
$response = $this->client->request('typo3content/_search?q=*:*');
|
||||
|
||||
$this->assertTrue($response->isOK());
|
||||
$this->assertSame($response->getData()['hits']['total'], 1, 'Not exactly 1 document was indexed.');
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue