diff --git a/Makefile b/Makefile
index ef9b947..92aeffc 100644
--- a/Makefile
+++ b/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
diff --git a/Tests/Functional/Fixtures/Indexing/IndexTcaTable.ts b/Tests/Functional/Fixtures/Indexing/IndexTcaTable.ts
new file mode 100644
index 0000000..22c4ed8
--- /dev/null
+++ b/Tests/Functional/Fixtures/Indexing/IndexTcaTable.ts
@@ -0,0 +1,12 @@
+plugin {
+ tx_searchcore {
+ settings {
+ connection {
+ host = localhost
+ port = 9200
+ }
+ }
+ }
+}
+
+module.tx_searchcore < plugin.tx_searchcore
diff --git a/Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml b/Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml
new file mode 100644
index 0000000..50532f2
--- /dev/null
+++ b/Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml
@@ -0,0 +1,69 @@
+
+
+
+ 1
+ 0
+ Page Title
+
+
+
+ 6
+ 1
+ 1480686370
+ 1480686370
+ 0
+ 72
+ textmedia
+
+ this is the content of textmedia content element that should get indexed
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
+
+
+ 7
+ 1
+ 1480686371
+ 1480686370
+ 0
+ 72
+ textmedia
+
+
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1481305963
+ 0
+ 0
+
+
+
+ 8
+ 1
+ 1480686370
+ 1480686370
+ 1
+ 72
+ textmedia
+
+
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
+
+
diff --git a/Tests/Functional/FunctionalTestCase.php b/Tests/Functional/FunctionalTestCase.php
new file mode 100644
index 0000000..bd04468
--- /dev/null
+++ b/Tests/Functional/FunctionalTestCase.php
@@ -0,0 +1,56 @@
+
+ *
+ * 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();
+ }
+}
diff --git a/Tests/Functional/FunctionalTests.xml b/Tests/Functional/FunctionalTests.xml
new file mode 100644
index 0000000..466358e
--- /dev/null
+++ b/Tests/Functional/FunctionalTests.xml
@@ -0,0 +1,22 @@
+
+
+
+
+ .
+
+
+
diff --git a/Tests/Functional/Indexing/IndexTcaTableTest.php b/Tests/Functional/Indexing/IndexTcaTableTest.php
new file mode 100644
index 0000000..57a6df6
--- /dev/null
+++ b/Tests/Functional/Indexing/IndexTcaTableTest.php
@@ -0,0 +1,56 @@
+
+ *
+ * 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.');
+ }
+}