Skip to content
This repository was archived by the owner on Nov 28, 2017. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ tests/codeception/tests/acceptance/*Tester.php
tests/codeception/tests/functional/*Tester.php
tests/codeception/tests/unit/*Tester.php

# Node modules #
node_modules/

# phpDocumentor Logs #
phpdoc-*

Expand Down
17 changes: 14 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Forces new Travis-CI Infrastructure
sudo: false

language: php

env:
Expand Down Expand Up @@ -67,10 +64,24 @@ before_script:
- if [[ $INSTALL_APCU_BC_BETA == "yes" ]]; then printf "\n" | pecl install apcu_bc-beta; fi
- if [[ $INSTALL_REDIS == "yes" && $TRAVIS_PHP_VERSION != hhvm ]]; then phpenv config-add build/travis/phpenv/redis.ini; fi
- if [[ $INSTALL_REDIS == "yes" && $TRAVIS_PHP_VERSION = hhvm ]]; then cat build/travis/phpenv/redis.ini >> /etc/hhvm/php.ini; fi
# Xvfb
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start
# Fluxbox
- sudo apt-get update -qq
- sudo apt-get install -y --force-yes firefox fluxbox
- fluxbox &
- sleep 3 # give fluxbox some time to start
#Make sure all node modules are installed
- cd tests/javascript
- npm install
- cd ../..

script:
- libraries/vendor/bin/phpunit --configuration travisci-phpunit.xml
- if [[ $RUN_PHPCS == "yes" ]]; then libraries/vendor/bin/phpcs --report=full --extensions=php -p --standard=build/phpcs/Joomla .; fi
- tests/javascript/node_modules/karma/bin/karma start karma.conf.js --single-run

branches:
except:
Expand Down
82 changes: 82 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Karma configuration

module.exports = function (config) {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine', 'requirejs'],

// list of files / patterns to load in the browser
files: [
{pattern: 'tests/javascript/node_modules/jquery/dist/jquery.min.js', included: false},
{pattern: 'tests/javascript/node_modules/jasmine-jquery/lib/jasmine-jquery.js', included: false},
{pattern: 'tests/javascript/node_modules/text/text.js', included: false},
{pattern: 'media/system/js/*.js', included: false},
{pattern: 'tests/javascript/**/fixture.html', included: false},
{pattern: 'tests/javascript/**/spec.js', included: false},
{pattern: 'tests/javascript/**/spec-setup.js', included: false},
{pattern: 'images/*.png', included: false},

'tests/javascript/test-main.js'
],

// list of files to exclude
exclude: [
'media/system/js/*uncompressed.js'
],

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'**/system/js/*!(uncompressed).js': ['coverage']
},

// coverage reporter configuration
coverageReporter: {
type : 'text'
},

// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['verbose', 'coverage'],

// web server port
port: 9876,

// enable / disable colors in the output (reporters and logs)
colors: true,

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,

// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Firefox'],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,

// list of plugins
plugins: [
'karma-jasmine',
'karma-firefox-launcher',
'karma-coverage',
'karma-requirejs',
'karma-verbose-reporter'
],

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
});
};
22 changes: 22 additions & 0 deletions tests/javascript/caption/fixtures/fixture.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<div id="captionjs">
<div id="single">
<img src="base/images/joomla_black.png" class="test" title="Joomla Title 1" />
</div>
<hr/>
<div id="multiple">
<img src="base/images/joomla_black.png" class="test" title="Joomla Title 1" />
<img src="base/images/powered_by.png" class="test" title="Joomla Title 2" align="right" width="100"/>
</div>
<hr/>
<div id="empty">
<img id="empty-title" src="base/images/joomla_black.png" class="test" title="" />
</div>
<hr/>
<div id="options">
<img id="no-options" src="base/images/joomla_black.png" class="test" title="Joomla Title 1"/>
<img id="width-attr" src="base/images/joomla_black.png" class="test" title="Joomla Title 2" width="100"/>
<img id="width-style" src="base/images/joomla_black.png" class="test" title="Joomla Title 3" style="width: 90px"/>
<img id="align-attr" src="base/images/joomla_black.png" class="test" title="Joomla Title 4" align="right"/>
<img id="align-style" src="base/images/joomla_black.png" class="test" title="Joomla Title 5" style="float: right"/>
</div>
</div>
17 changes: 17 additions & 0 deletions tests/javascript/caption/spec-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @package Joomla
* @subpackage JavaScript Tests
* @since 3.6
* @version 1.0.0
*/

define(['jquery', 'text!testsRoot/caption/fixtures/fixture.html', 'libs/caption', 'jasmineJquery'], function ($, fixture) {
$('body').append(fixture);

new JCaption('#single img.test');
new JCaption('#multiple img.test');
new JCaption('#empty img.test');
new JCaption('#options img.test');
});
68 changes: 68 additions & 0 deletions tests/javascript/caption/spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @package Joomla
* @subpackage JavaScript Tests
* @since 3.6
* @version 1.0.0
*/

define(['jquery', 'testsRoot/caption/spec-setup', 'jasmineJquery'], function ($) {

describe('JCaption applied to single image', function () {
it('Should have caption as "Joomla Title 1" under image', function () {
expect($('#single').find('p')).toHaveText('Joomla Title 1');
});
});

describe('JCaption applied for multiple images', function () {
it('Should have caption "Joomla Title 1" under image 1', function () {
expect($('#multiple').find('p').first()).toHaveText('Joomla Title 1');
});

it('Should have caption as "Joomla Title 2" under image 2', function() {
expect($('#multiple').find('p').last()).toHaveText('Joomla Title 2');
});
});

describe('JCaption with empty title attribute value', function () {
it('Should not have a <p> element inside the image container', function () {
expect($('#empty')).not.toContainElement('p');
});
});

describe('JCaption with no additional options', function () {
var $element = $('img#no-options');
it('Should have container CSS as {width: element.width, float: none}', function () {
expect($element.parent()).toHaveCss({
float: 'none'
});
});
});

describe('JCaption with additional options', function () {
it('Should have 2 elements with class right', function () {
expect($('#options').find('.right').length).toEqual(2);
});

it('Should have container width as 100 when element width attribute is set to 100', function () {
expect($('img#width-attr').parent().width()).toEqual(100);
});

it('Should have container width as 90 when element style is set to width: 90px', function () {
expect($('img#width-style').parent().width()).toEqual(90);
});

it('Should have float: right in container CSS when element attribute align is set to right', function () {
expect($('img#align-attr').parent()).toHaveCss({
float: 'right'
});
});

it('Should have float: right in container CSS when element style is set to float: right', function () {
expect($('img#align-style').parent()).toHaveCss({
float: 'right'
});
});
});
});
39 changes: 39 additions & 0 deletions tests/javascript/core/fixtures/fixture.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<div id="corejs">
<div id="submitform">
<form id="adminForm" onsubmit="return false"></form>
</div>
<div id="replace-tokens">
<input class="replace-tokens-input" type="hidden" value="1" name="123456789123456789123456789EDBCA">
<input class="replace-tokens-input" type="hidden" value="1" name="123456789123456789123456789EDBCA">
<input class="replace-tokens-input" id="invalid-type" type="submit" value="1" name="123456789123456789123456789EDBCA">
<input class="replace-tokens-input" id="invalid-value" type="hidden" value="0" name="123456789123456789123456789EDBCA">
<input class="replace-tokens-input" id="invalid-name" type="hidden" value="1" name="123">
</div>
<div id="check-all">
<input type="checkbox" id="cb-no-form" checked>
<form id="check-all-form">
<input type="checkbox" class="checked" id="cb0" checked>
<input type="checkbox" class="unchecked" id="cb1">
<input type="checkbox" class="unchecked" id="cb2">
<input type="checkbox" class="unchecked" id="no-cb3">
</form>
<form id="check-all-stub-form">
<input type="checkbox" id="stub-check-test-1" checked>
<input type="checkbox" id="stub-check-test-2">
</form>
</div>
<div id="render-messages-remove-messages">
<div id="system-message-container">
</div>
</div>
<div id="ischecked">
<form id="ischecked-test-form">
<input type="checkbox" id="check-all-box" name="checkall-toggle">
<input type="checkbox">
</form>
</div>
<div id="table-ordering">
<form id="table-ordering-test-form">
</form>
</div>
</div>
12 changes: 12 additions & 0 deletions tests/javascript/core/spec-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @package Joomla
* @subpackage JavaScript Tests
* @since 3.6
* @version 1.0.0
*/

define(['jquery', 'text!testsRoot/core/fixtures/fixture.html', 'libs/core', 'jasmineJquery'], function ($, fixture) {
$('body').append(fixture);
});
Loading