Skip to content

Commit 83e71b3

Browse files
committed
Add phpunit tests to drone
Remove old testing files Add postgres tests to drone
1 parent 0a29104 commit 83e71b3

File tree

8 files changed

+112
-76
lines changed

8 files changed

+112
-76
lines changed

.drone.yml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ steps:
3131
commands:
3232
- npm i --unsafe-perm
3333

34-
- name: prepare_system_tests
34+
- name: prepare_tests
3535
depends_on: [ npm ]
3636
image: joomlaprojects/docker-images:cypress8.2
3737
volumes:
@@ -50,13 +50,19 @@ steps:
5050

5151
- name: phpstan
5252
image: joomlaprojects/docker-images:php8.2
53-
depends_on: [ prepare_system_tests ]
53+
depends_on: [ prepare_tests ]
5454
failure: ignore
5555
commands:
5656
- vendor/bin/phpstan
5757

58+
- name: phpunit
59+
image: joomlaprojects/docker-images:php8.2
60+
depends_on: [ prepare_tests ]
61+
commands:
62+
- vendor/bin/phpunit
63+
5864
- name: phpmin-system-mysql
59-
depends_on: [ prepare_system_tests ]
65+
depends_on: [ prepare_tests ]
6066
image: joomlaprojects/docker-images:cypress8.2
6167
volumes:
6268
- name: cypress-cache
@@ -77,10 +83,33 @@ steps:
7783
- cd /drone/src
7884
- npx cypress run --browser=firefox --e2e --config baseUrl=http://localhost/mysql,screenshotsFolder=/drone/src/tests/cypress/output/screenshots
7985

86+
- name: phpmin-system-postgres
87+
depends_on: [ prepare_tests ]
88+
image: joomlaprojects/docker-images:cypress8.2
89+
volumes:
90+
- name: cypress-cache
91+
path: /root/.cache/Cypress
92+
commands:
93+
- mkdir /tests/www/mysql/
94+
- cp joomla.zip /tests/www/mysql/joomla.zip
95+
- cp dist/pkg-weblinks-current.zip /tests/www/mysql/pkg-weblinks-current.zip
96+
- cd /tests/www/mysql/
97+
- unzip joomla.zip
98+
- apache2ctl -D FOREGROUND &
99+
- chmod +rwx /root
100+
- php installation/joomla.php install --verbose --site-name="Joomla CMS test" [email protected] --admin-username=ci-admin --admin-user="jane doe" --admin-password=joomla-17082005 --db-type=pgsql --db-host=postgres --db-name=test_joomla --db-pass=joomla_ut --db-user=joomla_ut --db-encryption=0 --db-prefix=pgsql_
101+
- php cli/joomla.php config:set debug=true error_reporting=maximum
102+
- php cli/joomla.php extension:install --path=/tests/www/mysql/pkg-weblinks-current.zip
103+
- chmod -R 777 /tests/www/mysql/
104+
- chown -R www-data /tests/www/mysql/
105+
- cd /drone/src
106+
- npx cypress run --browser=firefox --e2e --config baseUrl=http://localhost/mysql,screenshotsFolder=/drone/src/tests/cypress/output/screenshots
107+
80108
- name: artifacts-system-tests
81109
image: joomlaprojects/docker-images:packager
82110
depends_on:
83111
- phpmin-system-mysql
112+
- phpmin-system-postgres
84113
environment:
85114
WEB_SERVER:
86115
from_secret: webserver
@@ -146,6 +175,6 @@ services:
146175

147176
---
148177
kind: signature
149-
hmac: 1190d2e4eaeb72929792b0cf79a9f08f534ddd34b0febf4244c82b51197e5e69
178+
hmac: 68328b184228b764a3ac96f00dc1ebe3b8f4e2dad5c4b0c0519ab0efbf6cec39
150179

151180
...

.drone/build.sh

Lines changed: 0 additions & 34 deletions
This file was deleted.

composer.json

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
{
2-
"name" : "joomla-extensions/weblinks",
3-
"description": "The Open Source PHP Framework for creating complex Joomla extensions",
4-
"license" : "GPL-2.0+",
5-
"config": {
6-
"platform": {
7-
"php": "8.2"
8-
}
9-
},
10-
"require" : {
11-
"php": "^8.2"
12-
},
13-
"require-dev": {
14-
"joomla-projects/jorobo": "^0.11.0",
15-
"phpunit/phpunit": "^9.6.0",
16-
"friendsofphp/php-cs-fixer": "^3.4.0",
17-
"squizlabs/php_codesniffer": "^3.7.1",
18-
"phpstan/phpstan": "^2.0",
19-
"phpstan/phpstan-deprecation-rules": "^2.0"
2+
"name" : "joomla-extensions/weblinks",
3+
"description": "The Open Source PHP Framework for creating complex Joomla extensions",
4+
"license" : "GPL-2.0+",
5+
"config": {
6+
"platform": {
7+
"php": "8.2"
8+
}
9+
},
10+
"autoload": {
11+
"psr-4": {
12+
"Joomla\\Component\\Weblinks\\Administrator\\": "src/administrator/components/com_weblinks/src",
13+
"Joomla\\Component\\Weblinks\\Site\\": "src/components/com_weblinks/src"
2014
}
15+
},
16+
"require" : {
17+
"php": "^8.2"
18+
},
19+
"require-dev": {
20+
"joomla-projects/jorobo": "^0.11.0",
21+
"phpunit/phpunit": "^9.6.0",
22+
"friendsofphp/php-cs-fixer": "^3.4.0",
23+
"squizlabs/php_codesniffer": "^3.7.1",
24+
"phpstan/phpstan": "^2.0",
25+
"phpstan/phpstan-deprecation-rules": "^2.0"
26+
}
2127
}

tests/_bootstrap.php

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/functional/_bootstrap.php

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/unit/UnitTestCase.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
/**
4+
* @package Joomla.UnitTest
5+
*
6+
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
7+
* @license GNU General Public License version 2 or later; see LICENSE.txt
8+
* @link http://www.phpunit.de/manual/current/en/installation.html
9+
*/
10+
11+
namespace Joomla\Tests\Unit;
12+
13+
use Joomla\Database\DatabaseInterface;
14+
use Joomla\Database\DatabaseQuery;
15+
use Joomla\Database\QueryInterface;
16+
17+
/**
18+
* Base Unit Test case for common behaviour across unit tests
19+
*
20+
* @since 4.0.0
21+
*/
22+
abstract class UnitTestCase extends \PHPUnit\Framework\TestCase
23+
{
24+
/**
25+
* Returns a database query instance.
26+
*
27+
* @param DatabaseInterface $db The database
28+
*
29+
* @return QueryInterface
30+
*
31+
* @since 4.2.0
32+
*/
33+
protected function getQueryStub(DatabaseInterface $db): QueryInterface
34+
{
35+
return new class ($db) extends DatabaseQuery {
36+
public function groupConcat($expression, $separator = ',')
37+
{
38+
}
39+
40+
public function processLimit($query, $limit, $offset = 0)
41+
{
42+
}
43+
};
44+
}
45+
}

tests/unit/_bootstrap.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,11 @@
1515
{
1616
define('JPATH_TESTS', realpath(__DIR__));
1717
}
18-
if (!defined('JPATH_TEST_DATABASE'))
19-
{
20-
define('JPATH_TEST_DATABASE', JPATH_TESTS . '/stubs/database');
21-
}
22-
if (!defined('JPATH_TEST_STUBS'))
23-
{
24-
define('JPATH_TEST_STUBS', JPATH_TESTS . '/stubs');
25-
}
2618

2719
// Installation path of joomla, we use the cache directory here (Robo run testing site)..
2820
if (!defined('JINSTALL_PATH'))
2921
{
30-
define('JINSTALL_PATH', dirname(JPATH_TESTS) . '/cache');
22+
define('JINSTALL_PATH', dirname(JPATH_TESTS, 2) . '/joomla');
3123
}
3224

3325
if (!defined('JPATH_PLATFORM'))
@@ -93,15 +85,13 @@
9385
define('JPATH_COMPONENT_ADMINISTRATOR', dirname(dirname(JPATH_BASE)) . '/src/administrator/component/com_weblinks');
9486
}
9587

96-
$_SERVER['HTTP_HOST'] = "localhost";
88+
require_once __DIR__ . '/UnitTestCase.php';
9789

98-
// Import the platform in legacy mode.
99-
require_once JPATH_PLATFORM . '/import.legacy.php';
90+
$_SERVER['HTTP_HOST'] = "localhost";
10091

10192
// Bootstrap the CMS libraries.
102-
require_once JPATH_LIBRARIES . '/cms.php';
93+
require_once JPATH_LIBRARIES . '/bootstrap.php';
10394

104-
require_once JPATH_PLATFORM . '/platform.php';
10595
require_once JPATH_PLATFORM . '/loader.php';
10696

10797
// Setup the autoloaders.

tests/unit/frontend/helper/WeblinksHelperRouteTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<?php
2+
3+
use Joomla\Component\Weblinks\Site\Helper\RouteHelper;
4+
use Joomla\Tests\Unit\UnitTestCase;
5+
26
/**
37
* @package Joomla.Administrator
48
* @subpackage com_weblinks
@@ -7,7 +11,7 @@
711
* @license GNU General Public License version 2 or later; see LICENSE.txt
812
*/
913

10-
class WeblinksHelperRouteTest extends \Codeception\TestCase\Test
14+
class WeblinksHelperRouteTest extends UnitTestCase
1115
{
1216
/**
1317
* @var \UnitTester
@@ -26,6 +30,6 @@ protected function _after()
2630
// tests
2731
public function testGetFormRouteNewWeblink()
2832
{
29-
$this->tester->assertContains('weblink.add&w_id=0', WeblinksHelperRoute::getFormRoute(null));
33+
$this->assertStringContainsString('weblink.add&w_id=0', RouteHelper::getFormRoute(null));
3034
}
3135
}

0 commit comments

Comments
 (0)