summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorknut <>2006-01-30 21:30:35 +0000
committerknut <>2006-01-30 21:30:35 +0000
commit48b3a6a236d229a203f5c20c705c901ee43ca4c2 (patch)
treeac01a4c4947b27af122a966eb39cbbce29b53861
parent14257165b0c3906181653c9a863edf87c1cf7366 (diff)
- Ported a few unit tests from the I18N package
- Moving report stylesheets to buildscripts/phing - Added a build/dist target for both standard distribution and PEAR package to build.xml
-rw-r--r--.gitattributes14
-rw-r--r--build.xml162
-rw-r--r--buildscripts/phing/style/coverage-frames.xsl (renamed from etc/style/coverage-frames.xsl)0
-rw-r--r--buildscripts/phing/style/log.xsl (renamed from etc/style/log.xsl)0
-rw-r--r--buildscripts/phing/style/phpunit2-frames.xsl (renamed from etc/style/phpunit2-frames.xsl)0
-rw-r--r--buildscripts/phing/style/phpunit2-noframes.xsl (renamed from etc/style/phpunit2-noframes.xsl)0
-rw-r--r--buildscripts/phing/style/str.replace.function.xsl (renamed from etc/style/str.replace.function.xsl)0
-rw-r--r--tests/unit/I18N/core/CultureInfoTest.php81
-rw-r--r--tests/unit/I18N/core/NumberFormatInfoTest.php88
-rw-r--r--tests/unit/I18N/core/NumberFormatTest.php (renamed from tests/unit/I18N/TNumberFormatTest.php)16
10 files changed, 333 insertions, 28 deletions
diff --git a/.gitattributes b/.gitattributes
index 8af5493f..426151cd 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -7,6 +7,11 @@ buildscripts/.htaccess -text
buildscripts/jsbuilder/build.php -text
buildscripts/jsbuilder/custom_rhino.jar -text
buildscripts/jsbuilder/packer.js -text
+buildscripts/phing/style/coverage-frames.xsl -text
+buildscripts/phing/style/log.xsl -text
+buildscripts/phing/style/phpunit2-frames.xsl -text
+buildscripts/phing/style/phpunit2-noframes.xsl -text
+buildscripts/phing/style/str.replace.function.xsl -text
buildscripts/phpbuilder/build.php -text
buildscripts/phpbuilder/files.txt -text
buildscripts/texbuilder/build.php -text
@@ -201,11 +206,6 @@ demos/quickstart/themes/Simple/style.css -text
docs/application.xml -text
docs/conceptual-structure.vsd -text
docs/request-sequence.vsd -text
-etc/style/coverage-frames.xsl -text
-etc/style/log.xsl -text
-etc/style/phpunit2-frames.xsl -text
-etc/style/phpunit2-noframes.xsl -text
-etc/style/str.replace.function.xsl -text
framework/.htaccess -text
framework/3rdParty/SafeHtml/HTMLSax3.php -text
framework/3rdParty/SafeHtml/HTMLSax3/Decorators.php -text
@@ -964,6 +964,8 @@ tests/UnitTests/simpletest/web_tester.php -text
tests/UnitTests/simpletest/xml.php -text
tests/unit/Collections/TListTest.php -text
tests/unit/Collections/TMapTest.php -text
-tests/unit/I18N/TNumberFormatTest.php -text
+tests/unit/I18N/core/CultureInfoTest.php -text
+tests/unit/I18N/core/NumberFormatInfoTest.php -text
+tests/unit/I18N/core/NumberFormatTest.php -text
tests/unit/TComponentTest.php -text
tests/unit/phpunit2.php -text
diff --git a/build.xml b/build.xml
index 0f239e71..ae7deecf 100644
--- a/build.xml
+++ b/build.xml
@@ -7,26 +7,54 @@
Phing > 2.1.1 (currently cvs HEAD needed)
xdebug >= 2.0.0beta4
PhpDocumentor >= 1.3.0RC5
-
+ PEAR >= 1.4.4
+ PEAR_PackageFileManager >= 1.6.0a4
-->
<project name="prado" basedir="." default="usage">
- <property name="version" value="3.0"/>
+ <property name="version" value="3.0.0"/>
+ <property name="state" value="stable"/>
<property name="pkgname" value="${phing.project.name}-${version}"/>
+ <property name="pkgname.pear" value="${pkgname}-pear"/>
<property name="src.dir" value="framework"/>
- <property name="doc.dir" value="docs/api"/>
+ <property name="doc.dir" value="docs"/>
+ <property name="doc.api.dir" value="${doc.dir}/api"/>
<property name="build.base.dir" value="build"/>
<property name="build.src.dir" value="${build.base.dir}/${pkgname}"/>
+ <property name="build.pear.dir" value="${build.base.dir}/${pkgname.pear}"/>
+ <property name="dist.base.dir" value="dist"/>
+ <property name="dist.zipfile" value="${dist.base.dir}/${pkgname}.zip"/>
+ <property name="dist.tarfile" value="${dist.base.dir}/${pkgname}.tar.gz"/>
+ <property name="dist.pearfile" value="${dist.base.dir}/${pkgname.pear}.tgz"/>
<property name="tests.dir" value="tests/unit"/>
<property name="reports.dir" value="reports"/>
<property name="reports.unit.dir" value="${reports.dir}/unit"/>
<property name="reports.codecoverage.dir" value="${reports.dir}/codecoverage"/>
- <property name="reports.style.dir" value="etc/style"/>
- <property name="reports.geshi.dir" value="framework/3rdParty/geshi"/>
+ <property name="reports.style.dir" value="buildscripts/phing/style"/>
+ <property name="reports.geshi.dir" value="${src.dir}/3rdParty/geshi"/>
+
+ <fileset dir="." id="src">
+ <exclude name="${src.dir}/**/.svn"/>
+ <include name="${src.dir}/**/*.php"/>
+ </fileset>
+
+ <fileset dir="." id="misc">
+ <include name="COPYRIGHT"/>
+ <include name="HISTORY"/>
+ <include name="UPGRADE"/>
+ <include name="index.html"/>
+ <exclude name="requirements/.svn"/>
+ <include name="requirements/*"/>
+ </fileset>
+
+ <fileset dir="." id="docs">
+ <exclude name="${doc.dir}/**/.svn"/>
+ <include name="${doc.dir}/**/*"/>
+ </fileset>
- <fileset dir="${src.dir}" id="source">
- <exclude name="**/.svn"/>
- <include name="**/*.php"/>
+ <fileset dir="." id="demos">
+ <exclude name="demos/**/.svn"/>
+ <include name="demos/**/*"/>
</fileset>
<target name="usage">
@@ -40,10 +68,26 @@
<echo message="clean --> Clean up the mess"/>
</target>
- <target name="doc">
- <echo>Generating API documentation</echo>
- <delete dir="${doc.dir}"/>
- <phpdoc title="PRADO ${version} documentation" destdir="${doc.dir}" sourcepath="${src.dir}" output="HTML:Smarty:PHP"/>
+ <target name="versioncheck" unless="version">
+ <echo message="====================================================="/>
+ <echo message="Version not specified. You must enter a version. In"/>
+ <echo message="the future you can add this to build.properties or"/>
+ <echo message="enter it on the command line: "/>
+ <echo message=" "/>
+ <echo message="-Dversion=3.0"/>
+ <echo message="====================================================="/>
+ <input propertyname="version" promptChar=":">PRADO version for package</input>
+
+ <property name="pkgname" value="${phing.project.name}-${version}" override="true"/>
+ <property name="build.src.dir" value="${build.base.dir}/${pkgname}" override="true"/>
+ <property name="dist.zipfile" value="${build.base.dir}/${pkgname}.zip" override="true"/>
+ <property name="dist.tarfile" value="${build.base.dir}/${pkgname}.tar.gz" override="true"/>
+ <property name="dist.pearfile" value="${build.base.dir}/${pkgname}-pear.tgz" override="true"/>
+ </target>
+
+ <target name="doc" description="Generating API documentation">
+ <delete dir="${doc.api.dir}"/>
+ <phpdoc title="PRADO ${version} API Documentation" destdir="${doc.api.dir}" sourcepath="${src.dir}" output="HTML:Smarty:PHP"/>
</target>
<target name="test">
@@ -92,17 +136,99 @@
</coverage-report>
</target>
- <target name="dist">
- <echo>TBD</echo>
+ <target name="build" depends="versioncheck,doc" description="Creating the main PRADO build">
+ <echo>Cleaning up after last build</echo>
+ <delete dir="${build.base.dir}"/>
+ <echo>Creating directory layout...</echo>
+ <copy todir="${build.src.dir}">
+ <fileset refid="src"/>
+ <fileset refid="docs"/>
+ <fileset refid="misc"/>
+ <fileset refid="demos"/>
+ </copy>
</target>
+ <target name="dist" depends="build" description="Creating the main PRADO distributions">
+ <delete dir="${dist.base.dir}"/>
+ <mkdir dir="${dist.base.dir}"/>
+ <tar compression="gzip" destFile="${dist.tarfile}" basedir="${build.base.dir}" />
+ <zip destfile="${dist.zipfile}" basedir="${build.base.dir}"/>
+ </target>
+
+ <target name="build-pear" depends="versioncheck">
+ <echo>Creating directory layout...</echo>
+ <delete dir="${build.base.dir}"/>
+ <copy todir="${build.pear.dir}">
+ <fileset refid="src"/>
+ </copy>
+ </target>
+
+ <target name="dist-pear" depends="build-pear">
+ <echo>Creating PEAR package.xml...</echo>
+ <pearpkg name="${phing.project.name}" dir="${build.pear.dir}" destFile="${build.pear.dir}/package.xml">
+ <fileset refid="src"/>
+ <fileset refid="docs"/>
+
+ <option name="notes">Release notes</option>
+
+ <!-- Set the simple options -->
+ <option name="summary">PRADO is a component-based and event-driven framework for rapid Web programming in PHP 5.</option>
+ <option name="description">test</option>
+ <option name="version" value="${version}"/>
+ <option name="extends" value="prado"/>
+ <option name="state" value="${state}"/>
+ <option name="license" value="BSD"/>
+
+ <!-- Set the complex options -->
+ <mapping name="maintainers">
+ <element>
+ <element key="handle" value="xue"/>
+ <element key="name" value="Qiang Xue"/>
+ <element key="email" value="qiang.xue@gmail.com"/>
+ <element key="role" value="lead"/>
+ </element>
+ <element>
+ <element key="handle" value="wei"/>
+ <element key="name" value="Xiang Wei Zhuo"/>
+ <element key="email" value="weizhuo@gmail.com"/>
+ <element key="role" value="lead"/>
+ </element>
+ </mapping>
+
+ <mapping name="deps">
+ <element>
+ <element key="type" value="php"/>
+ <element key="version" value="5.0.3"/>
+ <element key="rel" value="ge"/>
+ </element>
+ </mapping>
+
+ <mapping name="dir_roles">
+ <element key="docs" value="doc"/>
+ </mapping>
+
+ <mapping name="exceptions">
+ <element key="HISTORY" value="doc"/>
+ </mapping>
+ </pearpkg>
+
+ <echo>Validating package.xml</echo>
+ <exec command="pear package-validate package.xml" dir="${build.base.dir}" passthru="true"/>
+
+ <!--<echo>Converting package.xml from v1 to v2</echo>
+ <exec command="pear convert" dir="${build.base.dir}" passthru="true"/>-->
+
+ <echo>Creating tar.gz package...</echo>
+ <mkdir dir="${dist.base.dir}"/>
+ <tar compression="gzip" destFile="${dist.pearfile}" basedir="${build.base.dir}"/>
+ </target>
<target name="clean">
<echo>Cleaning up the mess</echo>
- <delete dir="${build.dir}"/>
- <delete dir="${doc.dir}"/>
- <delete dir="${reports.unit.dir}"/>
- <delete dir="${reports.codecoverage.dir}"/>
+ <delete dir="${build.base.dir}"/>
+ <delete dir="${dist.base.dir}"/>
+ <delete dir="${doc.api.dir}"/>
+ <delete dir="${reports.dir}"/>
</target>
</project> \ No newline at end of file
diff --git a/etc/style/coverage-frames.xsl b/buildscripts/phing/style/coverage-frames.xsl
index edfcf298..edfcf298 100644
--- a/etc/style/coverage-frames.xsl
+++ b/buildscripts/phing/style/coverage-frames.xsl
diff --git a/etc/style/log.xsl b/buildscripts/phing/style/log.xsl
index a460b667..a460b667 100644
--- a/etc/style/log.xsl
+++ b/buildscripts/phing/style/log.xsl
diff --git a/etc/style/phpunit2-frames.xsl b/buildscripts/phing/style/phpunit2-frames.xsl
index 7ccc4f33..7ccc4f33 100644
--- a/etc/style/phpunit2-frames.xsl
+++ b/buildscripts/phing/style/phpunit2-frames.xsl
diff --git a/etc/style/phpunit2-noframes.xsl b/buildscripts/phing/style/phpunit2-noframes.xsl
index d2c772da..d2c772da 100644
--- a/etc/style/phpunit2-noframes.xsl
+++ b/buildscripts/phing/style/phpunit2-noframes.xsl
diff --git a/etc/style/str.replace.function.xsl b/buildscripts/phing/style/str.replace.function.xsl
index 5d74e86c..5d74e86c 100644
--- a/etc/style/str.replace.function.xsl
+++ b/buildscripts/phing/style/str.replace.function.xsl
diff --git a/tests/unit/I18N/core/CultureInfoTest.php b/tests/unit/I18N/core/CultureInfoTest.php
new file mode 100644
index 00000000..14b60ece
--- /dev/null
+++ b/tests/unit/I18N/core/CultureInfoTest.php
@@ -0,0 +1,81 @@
+<?php
+require_once dirname(__FILE__).'/../../phpunit2.php';
+
+Prado::using('System.I18N.core.CultureInfo');
+
+/**
+ * @package System.I18N.core
+ */
+class CultureInfoTest extends PHPUnit2_Framework_TestCase {
+ protected $culture;
+
+ function setUp() {
+ $this->culture = CultureInfo::getInvariantCulture();
+ }
+
+ function testCultureName() {
+ $name = 'en';
+
+ $this->assertEquals($name, $this->culture->Name);
+
+ //the default/invariant culture should be neutral
+ $this->assertTrue($this->culture->IsNeutralCulture);
+ }
+
+ function testCultureList() {
+ $allCultures = CultureInfo::getCultures();
+ $neutralCultures = CultureInfo::getCultures(CultureInfo::NEUTRAL);
+ $specificCultures = CultureInfo::getCultures(CultureInfo::SPECIFIC);
+
+ //there should be 246 cultures all together.
+ $this->assertEquals(count($allCultures),246);
+ $this->assertEquals(count($neutralCultures),76);
+ $this->assertEquals(count($specificCultures),170);
+ }
+
+ function testParentCultures() {
+ $zh_CN = new CultureInfo('zh_CN');
+ $parent = $zh_CN->Parent;
+ $grandparent = $parent->Parent;
+
+ $this->assertEquals($zh_CN->Name, 'zh_CN');
+ $this->assertEquals($parent->Name, 'zh');
+ $this->assertEquals($grandparent->Name, 'en');
+ $this->assertEquals($grandparent->Parent->Name, 'en');
+ }
+
+ function testCountryNames() {
+ $culture = new CultureInfo('fr_FR');
+ $this->assertEquals($culture->Countries['AE'], 'Émirats arabes unis');
+ }
+
+ function testCurrencies() {
+ $culture = new CultureInfo('en_AU');
+ $au = array('$', 'Australian Dollar');
+ $this->assertEquals($au, $culture->Currencies['AUD']);
+ }
+
+ function testLanguages() {
+ $culture = new CultureInfo('fr_BE');
+ $this->assertEquals($culture->Languages['fr'], 'français');
+ }
+
+ function testScripts() {
+ $culture = new CultureInfo('fr');
+ $this->assertEquals($culture->Scripts['Armn'], 'arménien');
+ }
+
+ function testTimeZones() {
+ $culture = new CultureInfo('fi');
+ $zone = array(
+ "America/Los_Angeles",
+ "Tyynenmeren normaaliaika",
+ "PST",
+ "Tyynenmeren kesäaika",
+ "PDT",
+ "Los Angeles");
+ $this->assertEquals($culture->TimeZones[1],$zone);
+ }
+}
+
+?> \ No newline at end of file
diff --git a/tests/unit/I18N/core/NumberFormatInfoTest.php b/tests/unit/I18N/core/NumberFormatInfoTest.php
new file mode 100644
index 00000000..a3b6d05a
--- /dev/null
+++ b/tests/unit/I18N/core/NumberFormatInfoTest.php
@@ -0,0 +1,88 @@
+<?php
+require_once dirname(__FILE__).'/../../phpunit2.php';
+
+//NOTE: This page require UTF-8 aware editors
+Prado::using('System.I18N.core.NumberFormatInfo');
+
+/**
+ * @package System.I18N.core
+ */
+class NumberFormatInfoTest extends PHPUnit2_Framework_TestCase {
+
+ function testCurrencyPatterns() {
+ $numberInfo = NumberFormatInfo::getCurrencyInstance();
+
+ //there should be 2 decimal places.
+ $this->assertEquals($numberInfo->DecimalDigits,2);
+ $this->assertEquals($numberInfo->DecimalSeparator,'.');
+ $this->assertEquals($numberInfo->GroupSeparator,',');
+
+ //there should be only 1 grouping of size 3
+ $groupsize = array(3,false);
+ $this->assertEquals($numberInfo->GroupSizes, $groupsize);
+
+ //the default negative pattern prefix and postfix
+ $negPattern = array('-¤','');
+ $this->assertEquals($numberInfo->NegativePattern, $negPattern);
+
+ //the default positive pattern prefix and postfix
+ $negPattern = array('¤','');
+ $this->assertEquals($numberInfo->PositivePattern, $negPattern);
+
+ //the default currency symbol
+ $this->assertEquals($numberInfo->CurrencySymbol, 'US$');
+ $this->assertEquals($numberInfo->getCurrencySymbol('JPY'), '¥');
+ $this->assertEquals($numberInfo->NegativeInfinitySymbol, '-∞');
+ $this->assertEquals($numberInfo->PositiveInfinitySymbol, '+∞');
+ $this->assertEquals($numberInfo->NegativeSign, '-');
+ $this->assertEquals($numberInfo->PositiveSign, '+');
+ $this->assertEquals($numberInfo->NaNSymbol, '�');
+ $this->assertEquals($numberInfo->PercentSymbol, '%');
+ $this->assertEquals($numberInfo->PerMilleSymbol, '‰');
+ }
+
+ function testPatternsSet() {
+ $numberInfo = NumberFormatInfo::getInstance();
+
+ $numberInfo->DecimalDigits = 0;
+ $this->assertEquals($numberInfo->DecimalDigits,0);
+
+ $numberInfo->DecimalSeparator = ',';
+ $this->assertEquals($numberInfo->DecimalSeparator,',');
+
+ $numberInfo->GroupSeparator = ' ';
+ $this->assertEquals($numberInfo->GroupSeparator,' ');
+
+ $numberInfo->GroupSizes = array(2,3);
+ $groupsize = array(2,3);
+ $this->assertEquals($numberInfo->GroupSizes, $groupsize);
+
+ $numberInfo->NegativePattern = array('-$$','.');
+ $negPattern = array('-$$','.');
+ $this->assertEquals($numberInfo->NegativePattern, $negPattern);
+
+ $numberInfo->PositivePattern = array('YY','.');
+ $negPattern = array('YY','.');
+ $this->assertEquals($numberInfo->PositivePattern, $negPattern);
+
+ //the default CurrencySymbol symbol
+ $numberInfo->CurrencySymbol = '$$$';
+ $this->assertEquals($numberInfo->CurrencySymbol, '$$$');
+ }
+
+ function testLocalizedPatterns() {
+ $fr = NumberFormatInfo::getInstance('fr');
+ $de = NumberFormatInfo::getInstance('de');
+ $en = NumberFormatInfo::getInstance('en_US');
+
+ $this->assertEquals($fr->DecimalSeparator, ',');
+ $this->assertEquals($de->DecimalSeparator, ',');
+ $this->assertEquals($en->DecimalSeparator, '.');
+
+ $this->assertEquals($fr->GroupSeparator, ' ');
+ $this->assertEquals($de->GroupSeparator, '.');
+ $this->assertEquals($en->GroupSeparator, ',');
+ }
+}
+
+?> \ No newline at end of file
diff --git a/tests/unit/I18N/TNumberFormatTest.php b/tests/unit/I18N/core/NumberFormatTest.php
index 18e5f3ff..af6a06ca 100644
--- a/tests/unit/I18N/TNumberFormatTest.php
+++ b/tests/unit/I18N/core/NumberFormatTest.php
@@ -1,13 +1,13 @@
<?php
-require_once dirname(__FILE__).'/../phpunit2.php';
+require_once dirname(__FILE__).'/../../phpunit2.php';
//NOTE: This page require UTF-8 aware editors
Prado::using('System.I18N.core.NumberFormat');
/**
- * @package System.I18N
+ * @package System.I18N.core
*/
-class TNumberFormatTest extends PHPUnit2_Framework_TestCase {
+class NumberFormatTest extends PHPUnit2_Framework_TestCase {
function testDefaultFormats() {
$formatter = new NumberFormat();
$number = '123456789.125156';
@@ -91,13 +91,21 @@ class TNumberFormatTest extends PHPUnit2_Framework_TestCase {
$this->assertNotEquals($wanted, $formatter->format($number, $pattern));
}
- function testNegativeValue() {
+ function testFormatWithANegativeValue() {
$formatter = new NumberFormat();
$number = "-1.2";
$wanted = "-1.2";
$this->assertEquals($wanted, $formatter->format($number));
}
+
+ public function testFormatWithAScientificPattern() {
+ $formatter = new NumberFormat();
+ $number = "10";
+ $expected = "10E";
+ $this->assertEquals('10E', $formatter->format($number, 'e'));
+ }
+
}
?> \ No newline at end of file