Index: modules/custom/tests/functional/LoginTest.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- modules/custom/tests/functional/LoginTest.php (revision )
+++ modules/custom/tests/functional/LoginTest.php (revision )
@@ -0,0 +1,30 @@
+getSession();
+
+ $url = $this->Application->HREF('platform/my_account/my_account');
+ $session->visit($url);
+
+ $page = $session->getPage();
+ $content_box_titles = $page->findAll('css', '.content-box-title');
+
+ $this->assertTrue(count($content_box_titles) > 0, 'Page has content boxes');
+
+ if ( $content_box_titles ) {
+ $content_box_title = array_shift($content_box_titles);
+ /* @var $content_box_title \Behat\Mink\Element\NodeElement */
+
+ $this->assertEquals('User Registration', trim($content_box_title->getText()), 'Current page title');
+ }
+ }
+
+ public function testLoginFailure()
+ {
+ echo '';
+ }
+}
\ No newline at end of file
Index: tools/build/phpmd.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- tools/build/phpmd.xml (revision )
+++ tools/build/phpmd.xml (revision )
@@ -0,0 +1,11 @@
+
+ Description of your coding standard
+
+
+
+
\ No newline at end of file
Index: tools/composer.lock
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- tools/composer.lock (revision )
+++ tools/composer.lock (revision )
@@ -0,0 +1,226 @@
+{
+ "hash": "610c5736c3aeb585936463d27163f611",
+ "packages": [
+ {
+ "name": "behat/mink",
+ "version": "v1.4.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Behat/Mink.git",
+ "reference": "v1.4.0"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Behat/Mink/zipball/v1.4.0",
+ "reference": "v1.4.0",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.1",
+ "symfony/css-selector": ">=2.0.0,<2.2.0-dev"
+ },
+ "require-dev": {
+ "behat/mink-goutte-driver": "*",
+ "behat/mink-sahi-driver": "*",
+ "behat/mink-selenium-driver": "*",
+ "behat/mink-selenium2-driver": "*",
+ "behat/mink-zombie-driver": "*",
+ "symfony/finder": ">=2.0.0,<2.2.0-dev"
+ },
+ "suggest": {
+ "behat/mink-goutte-driver": "to enable Goutte support",
+ "behat/mink-sahi-driver": "to enable Sahi.JS support",
+ "behat/mink-selenium-driver": "to enable Selenium1 support",
+ "behat/mink-selenium2-driver": "to enable Selenium2 (webdriver support)",
+ "behat/mink-zombie-driver": "to enable Zombie.js support"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-0": {
+ "Behat\\Mink": "src/"
+ }
+ },
+ "notification-url": "http://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Konstantin Kudryashov",
+ "email": "ever.zet@gmail.com",
+ "homepage": "http://everzet.com"
+ }
+ ],
+ "description": "Web acceptance testing framework for PHP 5.3",
+ "homepage": "http://mink.behat.org/",
+ "keywords": [
+ "browser",
+ "testing",
+ "web"
+ ],
+ "time": "2012-05-29 22:50:10"
+ },
+ {
+ "name": "behat/mink-selenium2-driver",
+ "version": "v1.0.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Behat/MinkSelenium2Driver.git",
+ "reference": "v1.0.4"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Behat/MinkSelenium2Driver/zipball/v1.0.4",
+ "reference": "v1.0.4",
+ "shasum": ""
+ },
+ "require": {
+ "behat/mink": ">=1.4,<1.5-dev",
+ "instaclick/php-webdriver": ">=1.0,<1.1-dev",
+ "php": ">=5.3.1"
+ },
+ "type": "mink-driver",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Behat\\Mink\\Driver": "src/"
+ }
+ },
+ "notification-url": "http://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Konstantin Kudryashov",
+ "email": "ever.zet@gmail.com",
+ "homepage": "http://everzet.com"
+ },
+ {
+ "name": "Pete Otaqui",
+ "email": "pete@otaqui.com",
+ "homepage": "https://github.com/pete-otaqui"
+ }
+ ],
+ "description": "Selenium2 (WebDriver) driver for Mink framework",
+ "homepage": "http://mink.behat.org/",
+ "keywords": [
+ "ajax",
+ "browser",
+ "javascript",
+ "selenium",
+ "testing",
+ "webdriver"
+ ],
+ "time": "2013-02-17 15:32:01"
+ },
+ {
+ "name": "instaclick/php-webdriver",
+ "version": "1.0.12",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/instaclick/php-webdriver.git",
+ "reference": "1.0.12"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/instaclick/php-webdriver/zipball/1.0.12",
+ "reference": "1.0.12",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.2"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "WebDriver": "lib/"
+ }
+ },
+ "notification-url": "http://packagist.org/downloads/",
+ "license": [
+ "Apache-2.0"
+ ],
+ "authors": [
+ {
+ "name": "Justin Bishop",
+ "email": "jubishop@gmail.com",
+ "role": "Developer"
+ },
+ {
+ "name": "Anthon Pang",
+ "email": "apang@softwaredevelopment.ca",
+ "role": "developer"
+ }
+ ],
+ "description": "PHP WebDriver for Selenium 2",
+ "homepage": "http://instaclick.com/torontotechjobs/",
+ "keywords": [
+ "browser",
+ "selenium",
+ "webdriver",
+ "webtest"
+ ],
+ "time": "2013-02-19 18:37:07"
+ },
+ {
+ "name": "symfony/css-selector",
+ "version": "v2.1.8",
+ "target-dir": "Symfony/Component/CssSelector",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/CssSelector.git",
+ "reference": "v2.1.8"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/CssSelector/zipball/v2.1.8",
+ "reference": "v2.1.8",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\CssSelector": ""
+ }
+ },
+ "notification-url": "http://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony CssSelector Component",
+ "homepage": "http://symfony.com",
+ "time": "2013-01-09 08:51:07"
+ }
+ ],
+ "packages-dev": null,
+ "aliases": [
+
+ ],
+ "minimum-stability": "stable",
+ "stability-flags": {
+ "behat/mink": 0
+ }
+}
Index: tools/build/phpunit.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- tools/build/phpunit.xml (revision )
+++ tools/build/phpunit.xml (revision )
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+ ../../core/tests
+ ../../modules/*/tests
+ ../../core/tests/unit
+
+
+ ../../modules/custom/tests
+
+
+
+
+
+
+
+
+
+
+
+ ..
+
+
+ ../..
+
+ ../../blog
+ ../../modules/mpdf
+ ../../core/editor
+ ../../core/ckeditor
+ ../../system
+ ../../tools/vendor
+
+ ../../core/tests
+ ../../modules/*/tests
+
+ ../../core/kernel/tests/bootstrap.php
+
+
+
+
\ No newline at end of file
Index: core/kernel/tests/autoload.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/tests/autoload.php (revision )
+++ core/kernel/tests/autoload.php (revision )
@@ -0,0 +1,21 @@
+ '/test_case.php',
+ 'kMinkTestCase' => '/mink_test_case.php',
+ 'kMockFactory' => '/mock_factory.php',
+ );
+
+ $path = dirname(__FILE__);
+ }
+
+ if ( isset($classes[$class]) ) {
+ require $path . $classes[$class];
+ }
+});
+
Index: core/kernel/tests/bootstrap.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/tests/bootstrap.php (revision )
+++ core/kernel/tests/bootstrap.php (revision )
@@ -0,0 +1,14 @@
+Init();
+
+require_once(FULL_PATH . '/tools/vendor/autoload.php');
+require_once(dirname(__FILE__) . '/autoload.php');
Index: core/tests/unit/kernel/kBaseTest.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/tests/unit/kernel/kBaseTest.php (revision )
+++ core/tests/unit/kernel/kBaseTest.php (revision )
@@ -0,0 +1,48 @@
+object = new kBase();
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown()
+ {
+ }
+
+ public function testSettingPrefixOnly()
+ {
+ $this->object->Init('u', '');
+ $this->assertAttributeEquals('u', 'Prefix', $this->object);
+ $this->assertAttributeEquals('', 'Special', $this->object);
+ $this->assertEquals('u', $this->object->getPrefixSpecial());
+ }
+
+ public function testSettingPrefixAndSpecial()
+ {
+ $this->object->Init('u', 'simple-special');
+ $this->assertAttributeEquals('u', 'Prefix', $this->object);
+ $this->assertAttributeEquals('simple-special', 'Special', $this->object);
+ $this->assertEquals('u.simple-special', $this->object->getPrefixSpecial());
+ }
+}
Index: core/kernel/tests/mink_test_case.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/tests/mink_test_case.php (revision )
+++ core/kernel/tests/mink_test_case.php (revision )
@@ -0,0 +1,72 @@
+ Array ('type' => 'selenium2', 'browser' => 'firefox', 'host' => '10.0.0.1', 'port' => 4444),
+// 'selenium_chrome_mac10_8_2' => Array ('type' => 'selenium2', 'browser' => 'chrome', 'host' => '10.0.0.1', 'port' => 4444),
+ );
+ }
+
+ public static function setUpBeforeClass()
+ {
+ self::$mink = new \Behat\Mink\Mink();
+
+ $driver_configs = self::_getDriverConfig();
+
+ foreach ($driver_configs as $index => $driver_params) {
+ switch ( $driver_params['type'] ) {
+ case 'selenium2':
+ $driver = new \Behat\Mink\Driver\Selenium2Driver(
+ $driver_params['browser'], null, 'http://' . $driver_params['host'] . ':' . $driver_params['port'] . '/wd/hub'
+ );
+
+ $session = new \Behat\Mink\Session($driver);
+ break;
+
+ default:
+ throw new Exception('Unknown Mink driver type "' . $driver_params['type'] . '"');
+ break;
+ }
+
+ $session->start();
+
+ self::$mink->registerSession($index, $session);
+ }
+
+ reset($driver_configs);
+ self::$mink->setDefaultSessionName(key($driver_configs));
+ }
+
+ protected function setUp()
+ {
+ // TODO: maybe we shouldn't reset session before each test, because this would prevent
+ // TODO: multiple page testing together (e.g. login required checkout process)
+ static::$mink->resetSessions();
+ }
+
+ public static function tearDownAfterClass()
+ {
+ self::$mink->stopSessions();
+ }
+}
Index: core/tests/unit/kernel/utility/kEventTest.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/tests/unit/kernel/utility/kEventTest.php (revision )
+++ core/tests/unit/kernel/utility/kEventTest.php (revision )
@@ -0,0 +1,222 @@
+setEventParam('testing_completed', $event->MasterEvent->getEventParam('test_input'));
+
+ $sub_event = new kEvent($event->getPrefixSpecial() . ':OnTestingAncestor');
+ $this->Application->HandleEvent($sub_event);
+
+ $event->setEventParam('ancestor_test', $sub_event->getEventParam('ancestor_test'));
+ }
+
+ /**
+ * Event for testing
+ *
+ * @param kEvent $event
+ */
+ function OnTestingAncestor($event)
+ {
+ $event->setEventParam('ancestor_test', $event->hasAncestor('OnTesting'));
+ }
+}
+
+/**
+ * Test class for kEvent.
+ * Generated by PHPUnit on 2010-10-01 at 19:30:59.
+ */
+class kEventTest extends kTestCase
+{
+ /**
+ * @var kEvent
+ */
+ protected $object;
+
+ /**
+ * Sets up the fixture, for example, opens a network connection.
+ * This method is called before a test is executed.
+ */
+ protected function setUp()
+ {
+ $this->Application->removeObject('u_EventHandler');
+ $this->Application->registerClass('TestingEventHandler', __FILE__, 'u_EventHandler');
+
+ $specific_params = Array (
+ 'per_page' => 15,
+ 'tag_name' => 'Test',
+ );
+
+ $this->object = new kEvent('u.special:OnEventName', $specific_params);
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown()
+ {
+ $this->Application->unregisterClass('TestingEventHandler', 'u_EventHandler');
+ }
+
+ public function testOldStyleInit()
+ {
+ $event_params = Array (
+ 'prefix' => 'u',
+ 'special' => 'special',
+ 'name' => 'OnEventName',
+ );
+
+ $event = new kEvent($event_params);
+
+ $this->assertTrue($this->object->getPrefixSpecial() == 'u.special');
+ $this->assertTrue($this->object->getPrefixSpecial(true) == 'u_special');
+ }
+
+ public function testNewStyleInit()
+ {
+ $event = new kEvent('u.special:OnEventName');
+
+ $this->assertTrue($this->object->getPrefixSpecial() == 'u.special');
+ $this->assertTrue($this->object->getPrefixSpecial(true) == 'u_special');
+ }
+
+ public function testEventParams()
+ {
+ // manually set
+ $this->object->setEventParam('new_param', 'new_value');
+ $this->assertEquals('new_value', $this->object->getEventParam('new_param'));
+
+ // set during event init
+ $this->assertEquals(15, $this->object->getEventParam('per_page'));
+ $this->assertEquals('Test', $this->object->getEventParam('tag_name'));
+
+ // default value
+ $this->assertFalse( $this->object->getEventParam('unknown_param') );
+ }
+
+ public function testDefaultPseudoClass()
+ {
+ $object = $this->object->getContainer( Array ('skip_autoload' => true) );
+ $this->assertEquals($this->object->getPrefixSpecial(), $object->getPrefixSpecial());
+ $this->assertTrue( $object instanceof kDBItem );
+ $this->Application->removeObject( $object->getPrefixSpecial() );
+ }
+
+
+ public function testManualPseudoClass()
+ {
+ $this->object->setPseudoClass('_List');
+ $object = $this->object->getContainer();
+ $this->assertEquals($this->object->getPrefixSpecial(), $object->getPrefixSpecial());
+ $this->assertTrue( $object instanceof kDBList );
+ $this->Application->removeObject( $object->getPrefixSpecial() );
+ }
+
+ /**
+ * @depends testEventParams
+ */
+ public function testCallSubEvent()
+ {
+ $this->object->setEventParam('test_input', 'AA');
+ $this->object->CallSubEvent('OnTesting');
+ $this->assertEquals('AA', $this->object->getEventParam('testing_completed'));
+
+ $this->object->setEventParam('test_input', 'BB');
+ $this->object->CallSubEvent('u:OnTesting');
+ $this->assertEquals('BB', $this->object->getEventParam('testing_completed'));
+ }
+
+ public function testRedirectParams()
+ {
+ $this->object->SetRedirectParam('rparam_a', 'rparam_value');
+ $this->assertEquals('rparam_value', $this->object->getRedirectParam('rparam_a'));
+
+ $expected = Array (
+ 'rparam_a' => 'rparam_value'
+ );
+
+ $this->assertEquals(serialize($expected), serialize($this->object->getRedirectParams()));
+ }
+
+ /**
+ * @depends testRedirectParams
+ * @depends testEventParams
+ */
+ public function testCopyFromWithoutInheritance()
+ {
+ $src_event = new kEvent('prefix-a.special:OnLogin');
+ $src_event->redirect = 'redirect_template';
+ $src_event->SetRedirectParam('rparam_name', 'rparam_value');
+ $src_event->redirectScript = 'other.php';
+ $src_event->setEventParam('eparam_name', 'eparam_value');
+ $src_event->status = kEvent::erFAIL;
+
+ $dst_event = new kEvent('prefix-b.special:OnEvent');
+ $dst_event->copyFrom($src_event);
+
+ $this->assertEquals($src_event->redirect, $dst_event->redirect);
+ $this->assertEquals($src_event->getRedirectParam('rparam_name'), $dst_event->getRedirectParam('rparam_name'));
+ $this->assertEquals($src_event->redirectScript, $dst_event->redirectScript);
+ $this->assertEquals($src_event->getEventParam('eparam_name'), $dst_event->getEventParam('eparam_name'));
+ $this->assertEquals($dst_event->status, $src_event->status);
+ $this->assertNull( $dst_event->MasterEvent );
+ }
+
+ /**
+ * @depends testRedirectParams
+ * @depends testEventParams
+ */
+ public function testCopyFromWithInheritance()
+ {
+ $src_event = new kEvent('prefix-a.special:OnLogin');
+ $src_event->redirect = 'redirect_template';
+ $src_event->SetRedirectParam('rparam_name', 'rparam_value');
+ $src_event->redirectScript = 'other.php';
+ $src_event->setEventParam('eparam_name', 'eparam_value');
+ $src_event->status = kEvent::erFAIL;
+
+ $dst_event = new kEvent('prefix-b.special:OnEvent');
+ $dst_event->copyFrom($src_event, true);
+
+ $this->assertEquals($src_event->redirect, $dst_event->redirect);
+ $this->assertEquals($src_event->getRedirectParam('rparam_name'), $dst_event->getRedirectParam('rparam_name'));
+ $this->assertEquals($src_event->redirectScript, $dst_event->redirectScript);
+ $this->assertEquals($src_event->getEventParam('eparam_name'), $dst_event->getEventParam('eparam_name'));
+ $this->assertEquals($dst_event->status, kEvent::erSUCCESS);
+ $this->assertEquals(serialize($src_event), serialize($dst_event->MasterEvent));
+ }
+
+ /**
+ * @depends testCallSubEvent
+ */
+ public function testHasAncestor()
+ {
+ $this->object->CallSubEvent('OnTesting');
+ $this->assertTrue( $this->object->getEventParam('ancestor_test') );
+
+ $this->object->CallSubEvent('OnTestingAncestor');
+ $this->assertFalse( $this->object->getEventParam('ancestor_test') );
+ }
+
+ /**
+ * @depends testEventParams
+ */
+ public function testGetSection()
+ {
+ $actual = $this->object->getSection();
+ $this->assertEquals('in-portal:user_list', $actual);
+
+ $this->object->setEventParam('PermSection', 'local_override');
+ $actual = $this->object->getSection();
+ $this->assertEquals('local_override', $actual);
+
+
+ }
+}
Index: core/kernel/tests/mock_factory.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/tests/mock_factory.php (revision )
+++ core/kernel/tests/mock_factory.php (revision )
@@ -0,0 +1,28 @@
+getPublicMock($this->realClasses[$pseudo_class], $arguments);
+
+ return $object;
+ }
+}
\ No newline at end of file
Index: core/tests/unit/kernel/kDBBaseTest.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/tests/unit/kernel/kDBBaseTest.php (revision )
+++ core/tests/unit/kernel/kDBBaseTest.php (revision )
@@ -0,0 +1,458 @@
+ Array (
+ 'ResourceId' => Array ('required' => 1)
+ ),
+ );
+
+ $this->Application->SetVar('field_modifiers', $field_modifiers);
+
+ // virtually create date field for testing
+ $fields = $this->Application->getUnitOption('u-img', 'Fields');
+ $fields['DateField'] = Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#');
+ $this->Application->setUnitOption('u-img', 'Fields', $fields);
+
+ $this->object = new kDBBaseChild();
+ $this->object->Init('u-img', '');
+ $this->object->Configure();
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown()
+ {
+ $this->object = null;
+ }
+
+ private function getTempPrefix()
+ {
+ return 'ses_' . $this->Application->GetSID() . '_edit_';
+ }
+
+ public function testSwitchToTemp()
+ {
+ $correct_value = TABLE_PREFIX . $this->getTempPrefix() . $this->object->TableName;
+ $this->object->SwitchToTemp();
+
+ $this->assertAttributeEquals($correct_value, 'TableName', $this->object);
+ }
+
+ /**
+ * @depends testSwitchToTemp
+ */
+ public function testSwitchToLive()
+ {
+ $this->object->SwitchToTemp();
+ $correct_value = $this->Application->getUnitOption($this->object->Prefix, 'TableName');
+ $this->object->SwitchToLive();
+
+ $this->assertAttributeEquals($correct_value, 'TableName', $this->object);
+ }
+
+ /**
+ * @depends testSwitchToTemp
+ */
+ public function testIsTempTable()
+ {
+ $result = $this->object->IsTempTable();
+ $this->assertFalse($result);
+
+ $this->object->SwitchToTemp();
+ $result = $this->object->IsTempTable();
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @depends testSwitchToTemp
+ */
+ public function testQueryWithOccurenciesReplacing()
+ {
+ $this->object->SwitchToTemp();
+
+ $sql = 'SELECT %1$s.* %2$s
+ FROM %s
+ JOIN ' . TABLE_PREFIX . '%3$sUserGroupRelations ug ON ug.PortalUserId = %1$s.PortalUserId';
+ $this->object->SetSelectSQL($sql);
+
+ $result = $this->object->GetSelectSQL();
+ $temp_table = TABLE_PREFIX . $this->getTempPrefix() . $this->Application->GetLiveName($this->object->TableName);
+
+ $expected = ' SELECT ' . $temp_table . '.* %2$s
+ FROM ' . $temp_table . '
+ JOIN ' . TABLE_PREFIX . $this->getTempPrefix() . TABLE_PREFIX . 'UserGroupRelations ug ON ug.PortalUserId = ' . $temp_table . '.PortalUserId';
+
+ $this->assertEquals($this->removeWhitespaces($expected), $this->removeWhitespaces($result));
+ }
+
+ public function testQueryWithoutOccurenciesReplacing()
+ {
+ $sql = 'SELECT %1$s.* %2$s
+ FROM %s
+ JOIN ' . TABLE_PREFIX . '%3$sUserGroupRelations ug ON ug.PortalUserId = %1$s.PortalUserId';
+ $this->object->SetSelectSQL($sql);
+
+ $result = $this->object->GetSelectSQL(null, false);
+
+ $this->assertEquals($this->removeWhitespaces($sql), $this->removeWhitespaces($result));
+ }
+
+ public function testDefaultBaseQueryOverride()
+ {
+ $sql = 'SELECT %1$s.* %2$s
+ FROM %s
+ JOIN ' . TABLE_PREFIX . '%3$sUserGroupRelations ug ON ug.PortalUserId = %1$s.PortalUserId';
+ $this->object->SetSelectSQL($sql);
+
+ $result = $this->object->GetSelectSQL('new sql', false);
+
+ $this->assertEquals('new sql', $result);
+ }
+
+ public function testCalculatedFieldsDefining()
+ {
+ $fields = Array ('FieldA' => 'FieldAClause', 'FieldB' => 'FieldBClause');
+ $this->object->setCalculatedFields($fields);
+ $result = $this->object->getCalculatedFields();
+
+ $this->assertEquals(serialize($fields), serialize($result));
+ }
+
+ /**
+ * @depends testCalculatedFieldsDefining
+ */
+ public function testAddCalculatedField()
+ {
+ $fields = Array ('FieldA' => 'FieldAClause', 'FieldB' => 'FieldBClause');
+ $this->object->setCalculatedFields($fields);
+
+ $this->object->addCalculatedField('FieldB', 'OtherFieldBClause');
+ $result = $this->object->getCalculatedFields();
+ $this->assertTrue( array_key_exists('FieldB', $result) && ($result['FieldB'] == 'OtherFieldBClause') );
+
+ $this->object->addCalculatedField('FieldC', 'FieldCClause');
+ $result = $this->object->getCalculatedFields();
+ $this->assertTrue( array_key_exists('FieldC', $result) && ($result['FieldC'] == 'FieldCClause') );
+ }
+
+ public function testIsCalculatedField()
+ {
+ $fields = Array ('FieldA' => Array (), 'FieldB' => Array ());
+ $this->object->setCalculatedFields($fields);
+
+ $this->assertTrue( $this->object->isCalculatedField('FieldB') );
+ $this->assertFalse( $this->object->isCalculatedField('FieldC') );
+ }
+
+ public function testIncorrectCalculatedFieldTypeRetrieval()
+ {
+ $result = $this->object->getCalculatedFields(5555);
+ $this->assertEquals(serialize(Array ()), serialize($result));
+ }
+
+ public function testApplyFieldModifiers()
+ {
+ $field_required = $this->object->GetFieldOption('ResourceId', 'required');
+ $this->assertTrue( (bool)$field_required );
+ }
+
+ /**
+ * @depends testApplyFieldModifiers
+ */
+ public function testConfigure()
+ {
+ $this->assertAttributeEquals('ImageId', 'IDField', $this->object);
+ $this->assertAttributeEquals(TABLE_PREFIX . 'CatalogImages', 'TableName', $this->object);
+
+ // kDBBase::defineFields
+ $fields = array_keys( $this->Application->getUnitOption($this->object->Prefix, 'Fields') );
+ $actual_fields = array_keys( $this->object->getFields() );
+ $this->assertEquals(serialize(Array ()), serialize( array_diff($fields, $actual_fields) ));
+
+ $virtual_fields = array_keys( $this->Application->getUnitOption($this->object->Prefix, 'VirtualFields') );
+ $actual_virtual_fields = array_keys( $this->object->getVirtualFields() );
+ $this->assertEquals(serialize(Array ()), serialize( array_diff($virtual_fields, $actual_virtual_fields) ));
+
+ $custom_fields = $this->Application->getUnitOption($this->object->Prefix, 'CustomFields', Array ());
+ $this->assertEquals(serialize($custom_fields), serialize($this->object->getCustomFields()));
+
+ $calculated_fields = $this->Application->getUnitOption($this->object->Prefix, 'CalculatedFields');
+ $calculated_fields = array_keys( $calculated_fields[''] );
+ $actual_calculated_fields = array_keys( $this->object->getCalculatedFields() );
+ $this->assertEquals(serialize(Array ()), serialize( array_diff($calculated_fields, $actual_calculated_fields) ));
+
+ $aggregated_calculated_fields = $this->Application->getUnitOption($this->object->Prefix, 'AggregatedCalculatedFields');
+ $this->assertEquals(serialize(Array ()), serialize($this->object->getCalculatedFields(2)));
+
+ // kDBBase::ApplyFieldModifiers
+ $field_required = $this->object->GetFieldOption('ResourceId', 'required');
+ $this->assertTrue( (bool)$field_required );
+
+ // kDBBase::prepareConfigOptions
+ $this->assertTrue( $this->object->isVirtualField('DateField_date') );
+
+ // kDBBase::SetDefaultValues
+ $result = $this->object->GetFieldOption('dob', 'default');
+ $this->assertFalse($result === '#NOW#');
+ }
+
+ public function testAggregatedCalculatedFieldsDefining()
+ {
+ $fields = Array ('FieldA' => 'FieldAClause', 'FieldB' => 'FieldBClause');
+ $this->object->setAggregatedCalculatedFields($fields);
+ $result = $this->object->getCalculatedFields(2);
+
+ $this->assertEquals(serialize($fields), serialize($result));
+ }
+
+ public function testAggregatedAndNotAggregatedCalculatedFieldsRetrieval()
+ {
+ $calculated_fields = Array ('CalcFieldA' => 'CalcFieldAClause', 'CalcFieldB' => 'CalcFieldBClause');
+ $this->object->setCalculatedFields($calculated_fields);
+
+ $aggregated_fields = Array ('AggregFieldA' => 'AggregFieldAClause', 'AggregFieldB' => 'AggregFieldBClause');
+ $this->object->setAggregatedCalculatedFields($aggregated_fields);
+
+ $result = $this->object->getCalculatedFields(0);
+
+ $this->assertEquals(serialize(array_merge($calculated_fields, $aggregated_fields)), serialize($result));
+ }
+
+ public function testCustomFieldsDefining()
+ {
+ $fields = Array ('FieldA', 'FieldB');
+ $this->object->setCustomFields($fields);
+ $result = $this->object->getCustomFields();
+
+ $this->assertEquals(serialize($fields), serialize($result));
+ }
+
+ public function testFieldsDefining()
+ {
+ $fields = Array ('FieldA' => Array (), 'FieldB' => Array ());
+ $this->object->setFields($fields);
+ $result = $this->object->getFields();
+
+ $this->assertEquals(serialize($fields), serialize($result));
+ }
+
+ /**
+ * @depends testFieldsDefining
+ */
+ public function testIsField()
+ {
+ $fields = Array ('FieldA' => Array (), 'FieldB' => Array ());
+ $this->object->setFields($fields);
+
+ $this->assertTrue( $this->object->isField('FieldB') );
+ $this->assertFalse( $this->object->isField('FieldC') );
+ }
+
+ /**
+ * Virtual fields are overrited completely with given array
+ *
+ */
+ public function testVirtualFieldOverwrite()
+ {
+ $virtual_fields1 = Array ('VF1' => Array ('aa' => 'bb'), 'VF2' => Array ('aa2' => 'bb2'));
+ $this->object->setVirtualFields($virtual_fields1);
+
+ $virtual_fields2 = Array (
+ 'VF15' => Array ('aa15' => 'bb15'),
+ 'VF16' => Array ('aa16' => 'bb16'),
+ 'VF26' => Array ('aa26' => 'bb26'),
+ );
+ $this->object->setVirtualFields($virtual_fields2);
+
+ $result = $this->object->getVirtualFields();
+
+ $this->assertEquals(serialize($virtual_fields2), serialize($result));
+ }
+
+ /**
+ * Current real fields are merged with virtual fields in favor of real fields
+ *
+ * @depends testFieldsDefining
+ */
+ public function testVirtualFieldsMerge()
+ {
+ $fields = Array (
+ 'F1' => Array ('type' => 'string', 'default' => ''),
+ 'F2' => Array ('type' => 'int', 'default' => 0),
+ 'VF' => Array ('type' => 'orange', 'default' => 'yes'),
+ );
+ $this->object->setFields($fields);
+
+ $virtual_fields = Array (
+ 'VF1' => Array ('type' => 'string', 'default' => ''),
+ 'VF2' => Array ('type' => 'int', 'default' => 0),
+ 'VF' => Array ('type' => 'cyan', 'default' => 555, 'new_option' => 'op_value'),
+ );
+ $this->object->setVirtualFields($virtual_fields);
+
+ $result = $this->object->getFields();
+ $expected = array_merge($virtual_fields, $fields);
+
+ $this->assertEquals(serialize($expected), serialize($result));
+ }
+
+ /**
+ * Virtual fields not overrited, when setVirtualFields called with empty array - IF test
+ *
+ * @depends testVirtualFieldOverwrite
+ */
+ public function testVirtualFieldsSkipping()
+ {
+ $virtual_fields = Array ('VF1' => Array ('aa' => 'bb'), 'VF2' => Array ('aa2' => 'bb2'));
+ $this->object->setVirtualFields($virtual_fields);
+
+ $this->object->setVirtualFields( Array () );
+ $result = $this->object->getVirtualFields();
+
+ $this->assertEquals(serialize($virtual_fields), serialize($result));
+ }
+
+ public function testIsVirtualField()
+ {
+ $virtual_fields = Array (
+ 'VF1' => Array ('type' => 'string', 'default' => ''),
+ 'VF2' => Array ('type' => 'int', 'default' => 0),
+ 'VF' => Array ('type' => 'cyan', 'default' => 555, 'new_option' => 'op_value'),
+ );
+ $this->object->setVirtualFields($virtual_fields);
+
+ $this->assertTrue( $this->object->isVirtualField('VF2') );
+ $this->assertFalse( $this->object->isVirtualField('F1') );
+ }
+
+ /**
+ * @depends testFieldsDefining
+ */
+ public function testFieldOptionManupulationsForDBFields()
+ {
+ $field_options = Array ('type' => 'int', 'default' => 5);
+ $this->object->SetFieldOptions('RFieldName', $field_options);
+
+ $expected = Array ('type' => 'int', 'default' => 5, 'options_prepared' => true);
+ $actual = $this->object->GetFieldOptions('RFieldName');
+ $this->assertEquals(serialize($expected), serialize($actual));
+
+ $this->object->SetFieldOption('RFieldName', 'test_option', 'test_value');
+
+ $actual = $this->object->GetFieldOption('RFieldName', 'test_option', false, 'default_value');
+ $this->assertEquals('test_value', $actual);
+
+ $actual = $this->object->GetFieldOption('RFieldName', 'test_option2', false, 'default_value');
+ $this->assertEquals('default_value', $actual);
+ }
+
+ /**
+ * @depends testVirtualFieldOverwrite
+ * @depends testVirtualFieldsMerge
+ * @depends testVirtualFieldsSkipping
+ */
+ public function testFieldOptionManupulationsForVirtualFields()
+ {
+ $field_options = Array ('type' => 'int', 'default' => 5);
+ $this->object->SetFieldOptions('VFieldName', $field_options, true);
+ $actual = $this->object->GetFieldOptions('VFieldName', true);
+ $this->assertEquals(serialize($field_options), serialize($actual));
+
+ $this->object->SetFieldOption('VFieldName', 'test_option', 'test_value', true);
+
+ $actual = $this->object->GetFieldOption('VFieldName', 'test_option', true, 'default_value');
+ $this->assertEquals('test_value', $actual);
+
+ $actual = $this->object->GetFieldOption('VFieldName', 'test_option2', true, 'default_value');
+ $this->assertEquals('default_value', $actual);
+ }
+
+ public function testGetLinkedInfo()
+ {
+ $expected = Array (
+ 'TableName' => TABLE_PREFIX . 'CatalogImages',
+ 'IdField' => 'ImageId',
+ 'ForeignKey' => 'ResourceId',
+ 'ParentTableKey' => 'ResourceId',
+ 'ParentPrefix' => 'u',
+ 'ParentId' => 0,
+ );
+
+ $actual = $this->object->getLinkedInfo();
+ $this->assertEquals( serialize($expected), serialize($actual) );
+ }
+
+}
Index: tools/composer.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- tools/composer.json (revision )
+++ tools/composer.json (revision )
@@ -0,0 +1,6 @@
+{
+ "require": {
+ "behat/mink": "1.4@stable",
+ "behat/mink-selenium2-driver": "*"
+ }
+}
\ No newline at end of file
Index: core/kernel/tests/test_case.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/tests/test_case.php (revision )
+++ core/kernel/tests/test_case.php (revision )
@@ -0,0 +1,49 @@
+Application =& kApplication::Instance();
+ }
+
+ /**
+ * Removes whitespaces from a string
+ *
+ * @param string $string
+ * @return string
+ * @access protected
+ */
+ protected function removeWhitespaces($string)
+ {
+ return preg_replace('/\s+/', '', $string);
+ }
+
+ /**
+ * Allows to make getMock method called publicly
+ *
+ * @param string $class_name
+ * @param Array $arguments
+ * @return PHPUnit_Framework_MockObject_MockObject
+ */
+ public function getPublicMock($class_name, $arguments)
+ {
+ return $this->getMock($class_name, Array (), $arguments);
+ }
+}
\ No newline at end of file
Index: tools/build/phpcs.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- tools/build/phpcs.xml (revision )
+++ tools/build/phpcs.xml (revision )
@@ -0,0 +1,89 @@
+
+
+ In-Portal coding standard.
+
+ blog/*
+ modules/mpdf/*
+ core/editor/*
+ core/ckeditor/*
+ system/*
+ tools/vendor/*
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: tools/build/build.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- tools/build/build.xml (revision )
+++ tools/build/build.xml (revision )
@@ -0,0 +1,369 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <?php
+ $_CONFIG['Misc']['WriteablePath'] = '/system';
+ $_CONFIG['Misc']['RestrictedPath'] = '/system/.restricted';
+ $_CONFIG['Misc']['WebsitePath'] = '${website.path}';
+ $_CONFIG['Misc']['Domain'] = '${website.domain}';
+ $_CONFIG['Misc']['AdminDirectory'] = '/admin';
+ $_CONFIG['Misc']['AdminPresetsDirectory'] = '/admin';
+ $_CONFIG['Misc']['ApplicationClass'] = 'kApplication';
+ $_CONFIG['Misc']['ApplicationPath'] = '/core/kernel/application.php';
+ $_CONFIG['Misc']['CacheHandler'] = 'Fake';
+ $_CONFIG['Misc']['MemcacheServers'] = 'localhost:11211';
+ $_CONFIG['Misc']['CompressionEngine'] = 'php';
+ $_CONFIG['Misc']['WebsiteCharset'] = 'utf-8';
+ $_CONFIG['Misc']['EnableSystemLog'] = '1';
+ $_CONFIG['Misc']['SystemLogMaxLevel'] = '5';
+ $_CONFIG['Misc']['TrustProxy'] = '0';
+
+ $_CONFIG['Database']['DBType'] = 'mysql';
+ $_CONFIG['Database']['DBHost'] = '${db.host}';
+ $_CONFIG['Database']['DBName'] = '${db.name}';
+ $_CONFIG['Database']['DBUser'] = '${db.user}';
+ $_CONFIG['Database']['DBUserPassword'] = '${db.password}';
+ $_CONFIG['Database']['DBCollation'] = 'utf8_general_ci';
+ $_CONFIG['Database']['TablePrefix'] = '${db.tableprefix}';
+ $_CONFIG['Database']['DBCharset'] = 'utf8';
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: core/tests/unit/kernel/kEventHandlerTest.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/tests/unit/kernel/kEventHandlerTest.php (revision )
+++ core/tests/unit/kernel/kEventHandlerTest.php (revision )
@@ -0,0 +1,133 @@
+ 'OnTest',
+ );
+
+ $this->eventMethods = array_merge($this->eventMethods, $events_map);
+ }
+
+ /**
+ * Allows to override standard permission mapping
+ *
+ * @return void
+ * @access protected
+ * @see kEventHandler::$permMapping
+ */
+ protected function mapPermissions()
+ {
+ parent::mapPermissions();
+
+ $permissions = Array (
+ 'OnTrue' => Array ('self' => true),
+ 'OnFalse' => Array ('self' => 'view'),
+
+ );
+
+ $this->permMapping = array_merge($this->permMapping, $permissions);
+ }
+
+ /**
+ * Mapped test event
+ *
+ * @param kEvent $event
+ */
+ function OnTest($event)
+ {
+ $event->setEventParam('processed_in', 'OnTest');
+ $event->setEventParam('event_called', $event->Name);
+ }
+}
+
+/**
+ * Test class for kEventHandler.
+ * Generated by PHPUnit on 2010-10-20 at 11:24:12.
+ */
+class kEventHandlerTest extends kTestCase
+{
+ /**
+ * @var kEventHandler
+ */
+ protected $object;
+
+ /**
+ * Sets up the fixture, for example, opens a network connection.
+ * This method is called before a test is executed.
+ */
+ protected function setUp()
+ {
+ $this->object = new EEventHandler;
+ $this->object->Init('u', '');
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown()
+ {
+ }
+
+ public function testGetPrefixSpecial()
+ {
+ $this->setExpectedException('PHPUnit_Framework_Error', 'Usage of getPrefixSpecial() method is forbidden in kEventHandler class children. Use $event->getPrefixSpecial(true); instead', E_USER_ERROR);
+
+ $this->object->getPrefixSpecial();
+ }
+
+ public function testMissingEvent()
+ {
+ $this->setExpectedException('PHPUnit_Framework_Error', 'Event OnTestMissing not implemented in class EEventHandler', E_USER_ERROR);
+
+ $event = new kEvent('u:OnTestMissing');
+ $this->object->processEvent($event);
+ }
+
+ /**
+ * @depends testMissingEvent
+ */
+ public function testEventWithMapping()
+ {
+ $event = new kEvent('u:OnTestMapping');
+ $this->object->processEvent($event);
+
+ $this->assertEquals('OnTest', $event->getEventParam('processed_in'));
+ $this->assertEquals('OnTestMapping', $event->getEventParam('event_called'));
+ }
+
+ /**
+ * @depends testMissingEvent
+ */
+ public function testEventWithoutMapping()
+ {
+ $event = new kEvent('u:OnTest');
+ $this->object->processEvent($event);
+
+ $this->assertEquals('OnTest', $event->getEventParam('processed_in'));
+ $this->assertEquals('OnTest', $event->getEventParam('event_called'));
+ }
+
+ public function testPermissionMapping()
+ {
+ $_SERVER['REQUEST_URI'] = 'http://www.sample-site.com';
+
+ $event = new kEvent('u:OnTrue');
+ $this->assertTrue( $this->object->CheckPermission($event) );
+
+ $event = new kEvent('u:OnFalse');
+ $this->assertEquals( '0', $this->object->CheckPermission($event) );
+ }
+}
Index: tools/build/build.properties.dist
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- tools/build/build.properties.dist (revision )
+++ tools/build/build.properties.dist (revision )
@@ -0,0 +1,13 @@
+local.build=1
+base.dir=../..
+client.ip.address=
+cli.key=b674006f3edb1d9cd4d838c150b0567d
+
+website.domain=
+website.path=
+
+db.host=localhost
+db.user=
+db.password=
+db.name=
+db.tableprefix=
\ No newline at end of file