Skip to content
Snippets Groups Projects
Commit d8c33fbf authored by Demian Katz's avatar Demian Katz
Browse files

Separated integration tests requiring CI from unit tests that stand alone.

Resolves VUFIND-663.
parent afdbd94a
No related merge requests found
...@@ -139,7 +139,7 @@ ...@@ -139,7 +139,7 @@
</if> </if>
<!-- start Solr (use restart in case of old PID files) --> <!-- start Solr (use restart in case of old PID files) -->
<exec command="VUFIND_HOME=${srcdir} VUFIND_LOCAL_DIR=${srcdir}/local JETTY_PID=${tmp}/vufindtest.pid JETTY_CONSOLE=/dev/null ${srcdir}/vufind.sh restart" outputProperty="LASTOUTPUT" /> <exec command="VUFIND_HOME=${srcdir} VUFIND_LOCAL_DIR=${srcdir}/local JETTY_PID=${srcdir}/local/vufindtest.pid JETTY_CONSOLE=/dev/null ${srcdir}/vufind.sh restart" outputProperty="LASTOUTPUT" />
<echo message="${LASTOUTPUT}" /> <echo message="${LASTOUTPUT}" />
<!-- wait for Solor to finish spinning up --> <!-- wait for Solor to finish spinning up -->
...@@ -178,7 +178,7 @@ ...@@ -178,7 +178,7 @@
</if> </if>
<!-- stop Solr --> <!-- stop Solr -->
<exec command="VUFIND_HOME=${srcdir} VUFIND_LOCAL_DIR=${srcdir}/local JETTY_PID=${tmp}/vufindtest.pid ${srcdir}/vufind.sh stop" outputProperty="LASTOUTPUT" /> <exec command="VUFIND_HOME=${srcdir} VUFIND_LOCAL_DIR=${srcdir}/local JETTY_PID=${srcdir}/local/vufindtest.pid ${srcdir}/vufind.sh stop" outputProperty="LASTOUTPUT" />
<echo message="${LASTOUTPUT}" /> <echo message="${LASTOUTPUT}" />
<!-- delete the configuration, sample index, logs and cache data --> <!-- delete the configuration, sample index, logs and cache data -->
......
...@@ -245,4 +245,15 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase ...@@ -245,4 +245,15 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
} }
return $sm->get('VuFind\AuthPluginManager'); return $sm->get('VuFind\AuthPluginManager');
} }
/**
* Is this test running in a continuous integration context?
*
* @return bool
*/
public function continuousIntegrationRunning()
{
// We'll assume that if the CI Solr PID is present, then CI is active:
return file_exists(__DIR__ . '/../../../../../local/vufindtest.pid');
}
} }
...@@ -56,12 +56,31 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase ...@@ -56,12 +56,31 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase
*/ */
public static function setUpBeforeClass() public static function setUpBeforeClass()
{ {
// If CI is not running, all tests were skipped, so no work is necessary:
$test = new DatabaseTest();
if (!$test->continuousIntegrationRunning()) {
return;
}
// Fail if there are already users in the database (we don't want to run this // Fail if there are already users in the database (we don't want to run this
// on a real system -- it's only meant for the continuous integration server) // on a real system -- it's only meant for the continuous integration server)
$test = new DatabaseTest();
$userTable = $test->getTable('User'); $userTable = $test->getTable('User');
if (count($userTable->select()) > 0) { if (count($userTable->select()) > 0) {
throw new \Exception('Test cannot run with pre-existing user data!'); return $this->markTestSkipped(
'Test cannot run with pre-existing user data!'
);
}
}
/**
* Standard setup method.
*
* @return void
*/
public function setUp()
{
// Give up if we're not running in CI:
if (!$this->continuousIntegrationRunning()) {
return $this->markTestSkipped('Continuous integration not running.');
} }
} }
...@@ -274,6 +293,12 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase ...@@ -274,6 +293,12 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase
*/ */
public static function tearDownAfterClass() public static function tearDownAfterClass()
{ {
// If CI is not running, all tests were skipped, so no work is necessary:
$test = new DatabaseTest();
if (!$test->continuousIntegrationRunning()) {
return;
}
// Delete test user // Delete test user
$test = new DatabaseTest(); $test = new DatabaseTest();
$userTable = $test->getTable('User'); $userTable = $test->getTable('User');
......
...@@ -72,12 +72,31 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase ...@@ -72,12 +72,31 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase
*/ */
public static function setUpBeforeClass() public static function setUpBeforeClass()
{ {
// If CI is not running, all tests were skipped, so no work is necessary:
$test = new ILSTest();
if (!$test->continuousIntegrationRunning()) {
return;
}
// Fail if there are already users in the database (we don't want to run this // Fail if there are already users in the database (we don't want to run this
// on a real system -- it's only meant for the continuous integration server) // on a real system -- it's only meant for the continuous integration server)
$test = new ILSTest();
$userTable = $test->getTable('User'); $userTable = $test->getTable('User');
if (count($userTable->select()) > 0) { if (count($userTable->select()) > 0) {
throw new \Exception('Test cannot run with pre-existing user data!'); return $this->markTestSkipped(
'Test cannot run with pre-existing user data!'
);
}
}
/**
* Standard setup method.
*
* @return void
*/
public function setUp()
{
// Give up if we're not running in CI:
if (!$this->continuousIntegrationRunning()) {
return $this->markTestSkipped('Continuous integration not running.');
} }
} }
...@@ -176,6 +195,12 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase ...@@ -176,6 +195,12 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase
*/ */
public static function tearDownAfterClass() public static function tearDownAfterClass()
{ {
// If CI is not running, all tests were skipped, so no work is necessary:
$test = new ILSTest();
if (!$test->continuousIntegrationRunning()) {
return;
}
// Delete test user // Delete test user
$test = new ILSTest(); $test = new ILSTest();
$userTable = $test->getTable('User'); $userTable = $test->getTable('User');
......
...@@ -46,12 +46,31 @@ class ShibbolethTest extends \VuFindTest\Unit\DbTestCase ...@@ -46,12 +46,31 @@ class ShibbolethTest extends \VuFindTest\Unit\DbTestCase
*/ */
public static function setUpBeforeClass() public static function setUpBeforeClass()
{ {
// If CI is not running, all tests were skipped, so no work is necessary:
$test = new ShibbolethTest();
if (!$test->continuousIntegrationRunning()) {
return;
}
// Fail if there are already users in the database (we don't want to run this // Fail if there are already users in the database (we don't want to run this
// on a real system -- it's only meant for the continuous integration server) // on a real system -- it's only meant for the continuous integration server)
$test = new ShibbolethTest();
$userTable = $test->getTable('User'); $userTable = $test->getTable('User');
if (count($userTable->select()) > 0) { if (count($userTable->select()) > 0) {
throw new \Exception('Test cannot run with pre-existing user data!'); return $this->markTestSkipped(
'Test cannot run with pre-existing user data!'
);
}
}
/**
* Standard setup method.
*
* @return void
*/
public function setUp()
{
// Give up if we're not running in CI:
if (!$this->continuousIntegrationRunning()) {
return $this->markTestSkipped('Continuous integration not running.');
} }
} }
...@@ -215,8 +234,13 @@ class ShibbolethTest extends \VuFindTest\Unit\DbTestCase ...@@ -215,8 +234,13 @@ class ShibbolethTest extends \VuFindTest\Unit\DbTestCase
*/ */
public static function tearDownAfterClass() public static function tearDownAfterClass()
{ {
// Delete test user // If CI is not running, all tests were skipped, so no work is necessary:
$test = new ShibbolethTest(); $test = new ShibbolethTest();
if (!$test->continuousIntegrationRunning()) {
return;
}
// Delete test user
$userTable = $test->getTable('User'); $userTable = $test->getTable('User');
$user = $userTable->getByUsername('testuser', false); $user = $userTable->getByUsername('testuser', false);
if (empty($user)) { if (empty($user)) {
......
...@@ -38,6 +38,19 @@ namespace VuFindTest\Integration\Connection; ...@@ -38,6 +38,19 @@ namespace VuFindTest\Integration\Connection;
*/ */
class SolrTest extends \VuFindTest\Unit\TestCase class SolrTest extends \VuFindTest\Unit\TestCase
{ {
/**
* Standard setup method.
*
* @return void
*/
public function setUp()
{
// Give up if we're not running in CI:
if (!$this->continuousIntegrationRunning()) {
return $this->markTestSkipped('Continuous integration not running.');
}
}
/** /**
* Check AlphaBrowse "see also" functionality. * Check AlphaBrowse "see also" functionality.
* *
......
...@@ -39,6 +39,19 @@ use VuFind\Db\Table\ChangeTracker; ...@@ -39,6 +39,19 @@ use VuFind\Db\Table\ChangeTracker;
*/ */
class ChangeTrackerTest extends \VuFindTest\Unit\DbTestCase class ChangeTrackerTest extends \VuFindTest\Unit\DbTestCase
{ {
/**
* Standard setup method.
*
* @return void
*/
public function setUp()
{
// Give up if we're not running in CI:
if (!$this->continuousIntegrationRunning()) {
return $this->markTestSkipped('Continuous integration not running.');
}
}
/** /**
* Test change tracking * Test change tracking
* *
......
...@@ -39,6 +39,19 @@ use VuFind\View\Helper\Root\ResultFeed; ...@@ -39,6 +39,19 @@ use VuFind\View\Helper\Root\ResultFeed;
*/ */
class ResultFeedTest extends \VuFindTest\Unit\ViewHelperTestCase class ResultFeedTest extends \VuFindTest\Unit\ViewHelperTestCase
{ {
/**
* Standard setup method.
*
* @return void
*/
public function setUp()
{
// Give up if we're not running in CI:
if (!$this->continuousIntegrationRunning()) {
return $this->markTestSkipped('Continuous integration not running.');
}
}
/** /**
* Get plugins to register to support view helper being tested * Get plugins to register to support view helper being tested
* *
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment