[Beeframework-svn] SF.net SVN: beeframework:[11] trunk
Brought to you by:
b_hartmann,
m_plomer
|
From: <m_p...@us...> - 2011-12-12 18:20:45
|
Revision: 11
http://beeframework.svn.sourceforge.net/beeframework/?rev=11&view=rev
Author: m_plomer
Date: 2011-12-12 18:20:38 +0000 (Mon, 12 Dec 2011)
Log Message:
-----------
Added Paths:
-----------
trunk/tests/
trunk/tests/Bee/
trunk/tests/Bee/Annotations/
trunk/tests/Bee/Annotations/UtilsTest.php
trunk/tests/Bee/Context/
trunk/tests/Bee/Context/AbstractTest.php
trunk/tests/Bee/Context/Xml/
trunk/tests/Bee/Context/Xml/BeanDefinitionReaderTest-context.xml
trunk/tests/Bee/Context/Xml/BeanDefinitionReaderTest.php
trunk/tests/Bee/Utils/
trunk/tests/Bee/Utils/AntPathMatcherTest.php
trunk/tests/Bee/Utils/StringsTest.php
trunk/tests/bootstrap.php
trunk/tests/phpunit.xml
Added: trunk/tests/Bee/Annotations/UtilsTest.php
===================================================================
--- trunk/tests/Bee/Annotations/UtilsTest.php (rev 0)
+++ trunk/tests/Bee/Annotations/UtilsTest.php 2011-12-12 18:20:38 UTC (rev 11)
@@ -0,0 +1,67 @@
+<?php
+/*
+ * Copyright 2008-2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * User: mp
+ * Date: 01.07.11
+ * Time: 14:49
+ */
+
+class Bee_Annotations_UtilsTest /*extends PHPUnit_Framework_TestCase*/ {
+
+ public function testFindInheritedAnnotation() {
+
+ $class = new ReflectionClass('Bee_Annotations_UtilsTestChildAnnotatedClass');
+ $method = $class->getMethod('testMethod');
+
+ $annot = Bee_Annotations_Utils::findAnnotation($method, 'Bee_Annotations_UtilsTestAnnotation1');
+
+// $this->assertNotNull($annot, 'Annotation Bee_Annotations_UtilsTestAnnotation1 not found on Bee_Annotations_UtilsTestChildAnnotatedClass::testMethod()');
+//
+// $this->assertEquals('parentAnnotation', $annot->value);
+ }
+}
+
+class Bee_Annotations_UtilsTestAnnotation1 extends Annotation {
+ public $value;
+}
+
+class Bee_Annotations_UtilsTestAnnotation2 extends Annotation {
+ public $value;
+}
+
+class Bee_Annotations_UtilsTestParentAnnotatedClass {
+
+ /**
+ * @return void
+ *
+ * @Bee_Annotations_UtilsTestAnnotation1(value = "parentAnnotation")
+ */
+ public function testMethod() {
+ }
+}
+
+class Bee_Annotations_UtilsTestChildAnnotatedClass extends Bee_Annotations_UtilsTestParentAnnotatedClass {
+
+ /**
+ * @return void
+ *
+ * @Bee_Annotations_UtilsTestAnnotation2(value = "childAnnotation")
+ */
+ public function testMethod() {
+ }
+}
Property changes on: trunk/tests/Bee/Annotations/UtilsTest.php
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/tests/Bee/Context/AbstractTest.php
===================================================================
--- trunk/tests/Bee/Context/AbstractTest.php (rev 0)
+++ trunk/tests/Bee/Context/AbstractTest.php 2011-12-12 18:20:38 UTC (rev 11)
@@ -0,0 +1,103 @@
+<?php
+/*
+ * Copyright 2008-2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * User: mp
+ * Date: 06.07.11
+ * Time: 18:53
+ */
+
+class Bee_Context_AbstractTest extends PHPUnit_Framework_TestCase {
+
+ const BEAN_NAME_ARRAY_PARENT = 'arrayParent';
+ const BEAN_NAME_ARRAY_CHILD_MERGED = 'arrayChildMerged';
+ const BEAN_NAME_ARRAY_CHILD_NOT_MERGED = 'arrayChildNotMerged';
+
+ /**
+ * @var Bee_Context_Abstract
+ */
+ private $context;
+
+ protected function setUp() {
+ $this->context = new Bee_Context_AbstractTestStub('Bee_Context_AbstractTest');
+ }
+
+ /**
+ * @test
+ */
+ public function beanDefinitionCount() {
+ $this->assertEquals(3, $this->context->getBeanDefinitionCount());
+ }
+
+ /**
+ * @test
+ */
+ public function arrayMerged() {
+ $beanMerged = $this->context->getBean(self::BEAN_NAME_ARRAY_CHILD_MERGED);
+ $this->assertTrue(is_array($beanMerged));
+ $this->assertEquals(4, count($beanMerged));
+ }
+
+ /**
+ * @test
+ */
+ public function arrayNotMerged() {
+ $beanMerged = $this->context->getBean(self::BEAN_NAME_ARRAY_CHILD_NOT_MERGED);
+ $this->assertTrue(is_array($beanMerged));
+ $this->assertEquals(2, count($beanMerged));
+ }
+
+ /**
+ * @test
+ */
+ public function incomplete() {
+ $this->markTestIncomplete();
+ }
+}
+
+class Bee_Context_AbstractTestStub extends Bee_Context_Abstract {
+
+ protected function loadBeanDefinitions() {
+ $this->registerArrayFactoryParent();
+
+ $this->registerBeanDefinition(Bee_Context_AbstractTest::BEAN_NAME_ARRAY_CHILD_MERGED, $this->createArrayFactoryChild(true));
+ $this->registerBeanDefinition(Bee_Context_AbstractTest::BEAN_NAME_ARRAY_CHILD_NOT_MERGED, $this->createArrayFactoryChild(false));
+ }
+
+ private function registerArrayFactoryParent() {
+ $builder = Bee_Context_Support_BeanDefinitionBuilder::genericBeanDefinition('Bee_Context_Util_ArrayFactoryBean');
+ $list = array(
+ 'keyA' => new Bee_Context_Config_TypedStringValue('valueA'),
+ 'keyB' => new Bee_Context_Config_TypedStringValue('valueB'),
+ 'keyC' => new Bee_Context_Config_TypedStringValue('valueC')
+ );
+ $builder->addPropertyValue('sourceArray', new Bee_Context_Config_ArrayValue($list, false));
+ $this->registerBeanDefinition(Bee_Context_AbstractTest::BEAN_NAME_ARRAY_PARENT, $builder->getBeanDefinition());
+ }
+
+ private function createArrayFactoryChild($merge) {
+ $builder = Bee_Context_Support_BeanDefinitionBuilder::genericBeanDefinition('Bee_Context_Util_ArrayFactoryBean');
+ $list = array(
+ 'keyB' => new Bee_Context_Config_TypedStringValue('valueB_Child'),
+ 'keyD' => new Bee_Context_Config_TypedStringValue('valueD_Child'),
+ );
+ $builder->setParentName(Bee_Context_AbstractTest::BEAN_NAME_ARRAY_PARENT)
+ ->addPropertyValue('sourceArray', new Bee_Context_Config_ArrayValue($list, $merge));
+
+ return $builder->getBeanDefinition();
+ }
+}
Property changes on: trunk/tests/Bee/Context/AbstractTest.php
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/tests/Bee/Context/Xml/BeanDefinitionReaderTest-context.xml
===================================================================
--- trunk/tests/Bee/Context/Xml/BeanDefinitionReaderTest-context.xml (rev 0)
+++ trunk/tests/Bee/Context/Xml/BeanDefinitionReaderTest-context.xml 2011-12-12 18:20:38 UTC (rev 11)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="http://www.beeframework.org/schema/beans"
+ xmlns:util="http://www.beeframework.org/schema/util"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.beeframework.org/schema/beans http://www.beeframework.org/schema/beans/bee-beans-1.1.xsd
+ http://www.beeframework.org/schema/util http://www.beeframework.org/schema/beans/bee-utils-1.0.xsd" default-merge="true">
+
+ <bean name="referencedBean,alias1,alias2" class="Bee_Context_Util_ArrayFactoryBean" />
+
+ <util:array id="arrayFactory" scope="request">
+ <value>Alpha</value>
+ <value>Bravo</value>
+ <value>Charlie</value>
+ <assoc-item key="d">
+ <bean class="Bee_Context_Util_ArrayFactoryBean" />
+ </assoc-item>
+ <ref bean="referencedBean" />
+ </util:array>
+
+ <util:array id="childArrayFactoryMergedTrue" scope="request" parent="arrayFactory" merge="true">
+ <assoc-item key="d">
+ <ref bean="referencedBean" />
+ </assoc-item>
+ <value>Zulu</value>
+ </util:array>
+
+ <util:array id="childArrayFactoryMergedDefault" scope="request" parent="arrayFactory" merge="default">
+ <assoc-item key="d">
+ <ref bean="referencedBean" />
+ </assoc-item>
+ <value>Zulu</value>
+ </util:array>
+
+ <util:array id="childArrayFactoryMergedFalse" scope="request" parent="arrayFactory" merge="false">
+ <assoc-item key="d">
+ <ref bean="referencedBean" />
+ </assoc-item>
+ <value>Zulu</value>
+ </util:array>
+
+ <util:array id="childArrayFactoryMergedNone" scope="request" parent="arrayFactory">
+ <assoc-item key="d">
+ <ref bean="referencedBean" />
+ </assoc-item>
+ <value>Zulu</value>
+ </util:array>
+
+</beans>
Property changes on: trunk/tests/Bee/Context/Xml/BeanDefinitionReaderTest-context.xml
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/tests/Bee/Context/Xml/BeanDefinitionReaderTest.php
===================================================================
--- trunk/tests/Bee/Context/Xml/BeanDefinitionReaderTest.php (rev 0)
+++ trunk/tests/Bee/Context/Xml/BeanDefinitionReaderTest.php 2011-12-12 18:20:38 UTC (rev 11)
@@ -0,0 +1,141 @@
+<?php
+/*
+ * Copyright 2008-2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * User: mp
+ * Date: 03.07.11
+ * Time: 19:18
+ */
+
+class Bee_Context_Xml_BeanDefinitionReaderTest extends PHPUnit_Framework_TestCase {
+
+ /**
+ * @var Bee_Context_Config_BasicBeanDefinitionRegistry
+ */
+ private static $registry;
+
+ public static function setUpBeforeClass() {
+ self::$registry = new Bee_Context_Config_BasicBeanDefinitionRegistry();
+ $reader = new Bee_Context_Xml_BeanDefinitionReader(self::$registry);
+ $reader->loadBeanDefinitions('Bee/Context/Xml/BeanDefinitionReaderTest-context.xml');
+ }
+
+ /**
+ * @test
+ */
+ public function beanCount() {
+ $this->assertEquals(6, self::$registry->getBeanDefinitionCount());
+ }
+
+ /**
+ * @test
+ */
+ public function beanDefinition() {
+ $this->assertTrue(self::$registry->containsBeanDefinition('arrayFactory'));
+
+ $beanDefinition = self::$registry->getBeanDefinition('arrayFactory');
+
+ $this->assertInstanceOf('Bee_Context_Config_IBeanDefinition', $beanDefinition);
+
+ $this->assertEquals('Bee_Context_Util_ArrayFactoryBean', $beanDefinition->getBeanClassName());
+
+ $propValues = $beanDefinition->getPropertyValues();
+
+ $this->assertTrue(is_array($propValues));
+
+ $sourceArrayProp = $propValues['sourceArray'];
+ $this->assertInstanceOf('Bee_Beans_PropertyValue', $sourceArrayProp);
+
+ $this->assertEquals('sourceArray', $sourceArrayProp->getName());
+ }
+
+ /**
+ * @test
+ */
+ public function arrayFactoryDef() {
+ $beanDefinition = self::$registry->getBeanDefinition('arrayFactory');
+ $propValues = $beanDefinition->getPropertyValues();
+ $sourceArrayProp = $propValues['sourceArray'];
+
+ $arrayValue = $sourceArrayProp->getValue();
+
+ $this->assertArrayValueInstance($arrayValue, 5);
+
+ $this->checkParentArrayContents($arrayValue);
+
+ $this->assertInstanceOf('Bee_Context_Config_BeanDefinitionHolder', $arrayValue['d']);
+ }
+
+ /**
+ * @param Bee_Context_Config_ArrayValue $arrayValue
+ * @return void
+ */
+ private function checkParentArrayContents(Bee_Context_Config_ArrayValue $arrayValue) {
+ $this->assertTypedStringValue('Alpha', $arrayValue[0]);
+ $this->assertTypedStringValue('Bravo', $arrayValue[1]);
+ $this->assertTypedStringValue('Charlie', $arrayValue[2]);
+ $this->assertInstanceOf('Bee_Context_Config_RuntimeBeanReference', $arrayValue[3]);
+ }
+
+ /**
+ * @test
+ */
+ public function childArrayFactoryDefCheckMerge() {
+ $this->childArrayFactoryDefMerged('childArrayFactoryMergedTrue');
+ $this->childArrayFactoryDefMerged('childArrayFactoryMergedDefault');
+ $this->childArrayFactoryDefMerged('childArrayFactoryMergedNone');
+ $this->childArrayFactoryDefNotMerged('childArrayFactoryMergedFalse');
+ }
+
+ private function childArrayFactoryDefMerged($beanName) {
+ $arrayValue = $this->getSourceArrayValueForArrayFactory($beanName);
+ $this->assertArrayValueInstance($arrayValue, 6);
+ $this->checkParentArrayContents($arrayValue);
+ $this->assertInstanceOf('Bee_Context_Config_RuntimeBeanReference', $arrayValue['d']);
+ }
+
+ private function childArrayFactoryDefNotMerged($beanName) {
+ $arrayValue = $this->getSourceArrayValueForArrayFactory($beanName);
+ $this->assertArrayValueInstance($arrayValue, 2);
+ $this->assertInstanceOf('Bee_Context_Config_RuntimeBeanReference', $arrayValue['d']);
+ }
+
+ private function getSourceArrayValueForArrayFactory($beanName) {
+ $beanDefinition = self::$registry->getBeanDefinition($beanName);
+ $propValues = $beanDefinition->getPropertyValues();
+ $sourceArrayProp = $propValues['sourceArray'];
+ $this->assertInstanceOf('Bee_Beans_PropertyValue', $sourceArrayProp);
+ return $sourceArrayProp->getValue();
+ }
+
+ protected function assertTypedStringValue($stringValue, $propValue) {
+ $this->assertInstanceOf('Bee_Context_Config_TypedStringValue', $propValue);
+ $this->assertEquals($stringValue, $propValue->getValue());
+ }
+
+ protected function assertArrayValueInstance($arrayValue, $expectedSize) {
+ $this->assertInstanceOf('Bee_Context_Config_ArrayValue', $arrayValue);
+ $this->assertEquals($expectedSize, count($arrayValue));
+ }
+
+ /**
+ * @test
+ */
+ public function incomplete() {
+ $this->markTestIncomplete();
+ }
+}
\ No newline at end of file
Property changes on: trunk/tests/Bee/Context/Xml/BeanDefinitionReaderTest.php
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/tests/Bee/Utils/AntPathMatcherTest.php
===================================================================
--- trunk/tests/Bee/Utils/AntPathMatcherTest.php (rev 0)
+++ trunk/tests/Bee/Utils/AntPathMatcherTest.php 2011-12-12 18:20:38 UTC (rev 11)
@@ -0,0 +1,324 @@
+<?php
+/*
+ * Copyright 2008-2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * User: mp
+ * Date: 02.07.11
+ * Time: 15:00
+ */
+class Bee_Utils_AntPathMatcherTest extends PHPUnit_Framework_TestCase {
+
+ /**
+ * @var Bee_Utils_AntPathMatcher
+ */
+ private $pathMatcher;
+
+ protected function setUp() {
+ $this->pathMatcher = new Bee_Utils_AntPathMatcher();
+ }
+
+ /**
+ * @test
+ * @dataProvider matchDataProvider
+ */
+ public function match($pattern, $path, $result) {
+ $this->assertEquals($result, $this->pathMatcher->match($pattern, $path));
+ }
+
+ public function matchDataProvider() {
+ return array(
+ // test exact matching
+ array("test", "test", True), // #0
+ array("/test", "/test", True), // #1
+ array("/test.jpg", "test.jpg", False), // #2
+ array("test", "/test", False), // #3
+ array("/test", "test", False), // #4
+
+ // test matching with ?'s
+ array("t?st", "test", True), // #5
+ array("??st", "test", True), // #6
+ array("tes?", "test", True), // #7
+ array("te??", "test", True), // #8
+ array("?es?", "test", True), // #9
+ array("tes?", "tes", False), // #10
+ array("tes?", "testt", False),
+ array("tes?", "tsst", False),
+
+ // test matchin with *'s
+ array("*", "test", True),
+ array("test*", "test", True),
+ array("test*", "testTest", True), // #15
+ array("test/*", "test/Test", True),
+ array("test/*", "test/t", True),
+ array("test/*", "test/", True),
+ array("*test*", "AnothertestTest", True),
+ array("*test", "Anothertest", True), // #20
+ array("*.*", "test.", True),
+ array("*.*", "test.test", True),
+ array("*.*", "test.test.test", True),
+ array("test*aaa", "testblaaaa", True),
+ array("test*", "tst", False), // #25
+ array("test*", "tsttest", False),
+ array("test*", "test/", False),
+ array("test*", "test/t", False),
+ array("test/*", "test", False),
+ array("*test*", "tsttst", False), // #30
+ array("*test", "tsttst", False),
+ array("*.*", "tsttst", False),
+ array("test*aaa", "test", False),
+ array("test*aaa", "testblaaab", False),
+
+ // test matching with ?'s and /'s
+ array("/?", "/a", True), // #35
+ array("/?/a", "/a/a", True),
+ array("/a/?", "/a/b", True),
+ array("/??/a", "/aa/a", True),
+ array("/a/??", "/a/bb", True),
+ array("/?", "/a", True), // #40
+
+ // test matching with **'s
+ array("/**", "/testing/testing", True),
+ array("/*/**", "/testing/testing", True),
+ array("/**/*", "/testing/testing", True),
+ array("/bla/**/bla", "/bla/testing/testing/bla", True),
+ array("/bla/**/bla", "/bla/testing/testing/bla/bla", True), // #45
+ array("/**/test", "/bla/bla/test", True),
+ array("/bla/**/**/bla", "/bla/bla/bla/bla/bla/bla", True),
+ array("/bla*bla/test", "/blaXXXbla/test", True),
+ array("/*bla/test", "/XXXbla/test", True),
+ array("/bla*bla/test", "/blaXXXbl/test", False), // #50
+ array("/*bla/test", "XXXblab/test", False),
+ array("/*bla/test", "XXXbl/test", False),
+
+ array("/????", "/bala/bla", False),
+ array("/**/*bla", "/bla/bla/bla/bbb", False),
+
+ array("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing/", True), // #55
+ array("/*bla*/**/bla/*", "/XXXblaXXXX/testing/testing/bla/testing", True),
+ array("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing", True),
+ array("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing.jpg", True),
+
+ array("*bla*/**/bla/**", "XXXblaXXXX/testing/testing/bla/testing/testing/", True),
+ array("*bla*/**/bla/*", "XXXblaXXXX/testing/testing/bla/testing", True), // #60
+ array("*bla*/**/bla/**", "XXXblaXXXX/testing/testing/bla/testing/testing", True),
+ array("*bla*/**/bla/*", "XXXblaXXXX/testing/testing/bla/testing/testing", False),
+
+ array("/x/x/**/bla", "/x/x/x/", False),
+
+ array("", "", True)//,
+
+// array("/{bla}.*", "/testing.html", True) // #65
+ );
+ }
+
+ /**
+ * @test
+ * @dataProvider withMatchStartDataProvider
+ */
+ public function withMatchStart($pattern, $path, $result) {
+ $this->assertEquals($result, $this->pathMatcher->matchStart($pattern, $path));
+ }
+
+ public function withMatchStartDataProvider() {
+ return array(
+ // test exact matching
+ array("test", "test", True),
+ array("/test", "/test", True),
+ array("/test.jpg", "test.jpg", False),
+ array("test", "/test", False),
+ array("/test", "test", False),
+
+ // test matching with ?'s
+ array("t?st", "test", True),
+ array("??st", "test", True),
+ array("tes?", "test", True),
+ array("te??", "test", True),
+ array("?es?", "test", True),
+ array("tes?", "tes", False),
+ array("tes?", "testt", False),
+ array("tes?", "tsst", False),
+
+ // test matchin with *'s
+ array("*", "test", True),
+ array("test*", "test", True),
+ array("test*", "testTest", True),
+ array("test/*", "test/Test", True),
+ array("test/*", "test/t", True),
+ array("test/*", "test/", True),
+ array("*test*", "AnothertestTest", True),
+ array("*test", "Anothertest", True),
+ array("*.*", "test.", True),
+ array("*.*", "test.test", True),
+ array("*.*", "test.test.test", True),
+ array("test*aaa", "testblaaaa", True),
+ array("test*", "tst", False),
+ array("test*", "test/", False),
+ array("test*", "tsttest", False),
+ array("test*", "test/", False),
+ array("test*", "test/t", False),
+ array("test/*", "test", True),
+ array("test/t*.txt", "test", True),
+ array("*test*", "tsttst", False),
+ array("*test", "tsttst", False),
+ array("*.*", "tsttst", False),
+ array("test*aaa", "test", False),
+ array("test*aaa", "testblaaab", False),
+
+ // test matching with ?'s and /'s
+ array("/?", "/a", True),
+ array("/?/a", "/a/a", True),
+ array("/a/?", "/a/b", True),
+ array("/??/a", "/aa/a", True),
+ array("/a/??", "/a/bb", True),
+ array("/?", "/a", True),
+
+ // test matching with **'s
+ array("/**", "/testing/testing", True),
+ array("/*/**", "/testing/testing", True),
+ array("/**/*", "/testing/testing", True),
+ array("test*/**", "test/", True),
+ array("test*/**", "test/t", True),
+ array("/bla/**/bla", "/bla/testing/testing/bla", True),
+ array("/bla/**/bla", "/bla/testing/testing/bla/bla", True),
+ array("/**/test", "/bla/bla/test", True),
+ array("/bla/**/**/bla", "/bla/bla/bla/bla/bla/bla", True),
+ array("/bla*bla/test", "/blaXXXbla/test", True),
+ array("/*bla/test", "/XXXbla/test", True),
+ array("/bla*bla/test", "/blaXXXbl/test", False),
+ array("/*bla/test", "XXXblab/test", False),
+ array("/*bla/test", "XXXbl/test", False),
+
+ array("/????", "/bala/bla", False),
+ array("/**/*bla", "/bla/bla/bla/bbb", True),
+
+ array("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing/", True),
+ array("/*bla*/**/bla/*", "/XXXblaXXXX/testing/testing/bla/testing", True),
+ array("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing", True),
+ array("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing.jpg", True),
+
+ array("*bla*/**/bla/**", "XXXblaXXXX/testing/testing/bla/testing/testing/", True),
+ array("*bla*/**/bla/*", "XXXblaXXXX/testing/testing/bla/testing", True),
+ array("*bla*/**/bla/**", "XXXblaXXXX/testing/testing/bla/testing/testing", True),
+ array("*bla*/**/bla/*", "XXXblaXXXX/testing/testing/bla/testing/testing", True),
+
+ array("/x/x/**/bla", "/x/x/x/", True),
+
+ array("", "", True)
+ );
+ }
+
+ /**
+ * @test
+ * @dataProvider uniqueDeliminatorDataProvider
+ */
+ public function uniqueDeliminator($pattern, $path, $result) {
+ $this->pathMatcher->setPathSeparator(".");
+ $this->assertEquals($result, $this->pathMatcher->match($pattern, $path));
+ }
+
+ public function uniqueDeliminatorDataProvider() {
+ return array(
+ // test exact matching
+ array("test", "test", True),
+ array(".test", ".test", True),
+ array(".test/jpg", "test/jpg", False),
+ array("test", ".test", False),
+ array(".test", "test", False),
+
+ // test matching with ?'s
+ array("t?st", "test", True),
+ array("??st", "test", True),
+ array("tes?", "test", True),
+ array("te??", "test", True),
+ array("?es?", "test", True),
+ array("tes?", "tes", False),
+ array("tes?", "testt", False),
+ array("tes?", "tsst", False),
+
+ // test matchin with *'s
+ array("*", "test", True),
+ array("test*", "test", True),
+ array("test*", "testTest", True),
+ array("*test*", "AnothertestTest", True),
+ array("*test", "Anothertest", True),
+ array("*/*", "test/", True),
+ array("*/*", "test/test", True),
+ array("*/*", "test/test/test", True),
+ array("test*aaa", "testblaaaa", True),
+ array("test*", "tst", False),
+ array("test*", "tsttest", False),
+ array("*test*", "tsttst", False),
+ array("*test", "tsttst", False),
+ array("*/*", "tsttst", False),
+ array("test*aaa", "test", False),
+ array("test*aaa", "testblaaab", False),
+
+ // test matching with ?'s and .'s
+ array(".?", ".a", True),
+ array(".?.a", ".a.a", True),
+ array(".a.?", ".a.b", True),
+ array(".??.a", ".aa.a", True),
+ array(".a.??", ".a.bb", True),
+ array(".?", ".a", True),
+
+ // test matching with **'s
+ array(".**", ".testing.testing", True),
+ array(".*.**", ".testing.testing", True),
+ array(".**.*", ".testing.testing", True),
+ array(".bla.**.bla", ".bla.testing.testing.bla", True),
+ array(".bla.**.bla", ".bla.testing.testing.bla.bla", True),
+ array(".**.test", ".bla.bla.test", True),
+ array(".bla.**.**.bla", ".bla.bla.bla.bla.bla.bla", True),
+ array(".bla*bla.test", ".blaXXXbla.test", True),
+ array(".*bla.test", ".XXXbla.test", True),
+ array(".bla*bla.test", ".blaXXXbl.test", False),
+ array(".*bla.test", "XXXblab.test", False),
+ array(".*bla.test", "XXXbl.test", False)
+ );
+ }
+
+ /**
+ * @test
+ * @dataProvider extractPathWithinPatternDataProvider
+ */
+ public function extractPathWithinPattern($pattern, $path, $result) {
+ $this->assertEquals($result, $this->pathMatcher->extractPathWithinPattern($pattern, $path));
+ }
+
+ public function extractPathWithinPatternDataProvider() {
+ return array (
+ array("/docs/commit.html", "/docs/commit.html", ""),
+
+ array("/docs/*", "/docs/cvs/commit", "cvs/commit"),
+ array("/docs/cvs/*.html", "/docs/cvs/commit.html", "commit.html"),
+ array("/docs/**", "/docs/cvs/commit", "cvs/commit"),
+ array("/docs/**/*.html", "/docs/cvs/commit.html", "cvs/commit.html"),
+ array("/docs/**/*.html", "/docs/commit.html", "commit.html"),
+ array("/*.html", "/commit.html", "commit.html"),
+ array("/*.html", "/docs/commit.html", "docs/commit.html"),
+ array("*.html", "/commit.html", "/commit.html"),
+ array("*.html", "/docs/commit.html", "/docs/commit.html"),
+ array("**/*.*", "/docs/commit.html", "/docs/commit.html"),
+ array("*", "/docs/commit.html", "/docs/commit.html"),
+
+ array("/d?cs/*", "/docs/cvs/commit", "docs/cvs/commit"),
+ array("/docs/c?s/*.html", "/docs/cvs/commit.html", "cvs/commit.html"),
+ array("/d?cs/**", "/docs/cvs/commit", "docs/cvs/commit"),
+ array("/d?cs/**/*.html", "/docs/cvs/commit.html", "docs/cvs/commit.html")
+ );
+ }
+}
Property changes on: trunk/tests/Bee/Utils/AntPathMatcherTest.php
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/tests/Bee/Utils/StringsTest.php
===================================================================
--- trunk/tests/Bee/Utils/StringsTest.php (rev 0)
+++ trunk/tests/Bee/Utils/StringsTest.php 2011-12-12 18:20:38 UTC (rev 11)
@@ -0,0 +1,195 @@
+<?php
+/*
+ * Copyright 2008-2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * User: mp
+ * Date: 02.07.11
+ * Time: 15:16
+ */
+
+class Bee_Utils_StringsTest extends PHPUnit_Framework_TestCase {
+
+ /**
+ * @test
+ */
+ public function hasLength() {
+ $this->assertTrue(Bee_Utils_Strings::hasLength(" "));
+ $this->assertTrue(Bee_Utils_Strings::hasLength("abc "));
+
+ $this->assertFalse(Bee_Utils_Strings::hasLength(""));
+ $this->assertFalse(Bee_Utils_Strings::hasLength(null));
+ }
+
+ /**
+ * @test
+ * @expectedException Bee_Exceptions_TypeMismatch
+ */
+ public function hasLengthTypeMismatch() {
+ Bee_Utils_Strings::hasLength(array("test")); // should throw Bee_Exceptions_TypeMismatch
+ }
+
+ /**
+ * @test
+ */
+ public function hasText() {
+ $blank = " ";
+ $this->assertFalse(Bee_Utils_Strings::hasText($blank));
+
+ $this->assertFalse(Bee_Utils_Strings::hasText(null));
+ $this->assertFalse(Bee_Utils_Strings::hasText(""));
+
+ $this->assertTrue(Bee_Utils_Strings::hasText("t"));
+ }
+
+ /**
+ * @test
+ * @expectedException Bee_Exceptions_TypeMismatch
+ */
+ public function hasTextTypeMismatch() {
+ Bee_Utils_Strings::hasText(array("test")); // should throw Bee_Exceptions_TypeMismatch
+ }
+
+ /**
+ * @test
+ */
+ public function tokenizeToArrayKeys() {
+ $sa = Bee_Utils_Strings::tokenizeToArrayKeys("a,b , ,c", ",");
+ $this->assertEquals(3, count($sa));
+ $this->assertTrue($sa["a"] === true && $sa["b"] === true && $sa["c"] === true, "components are not correct");
+
+ $sa = Bee_Utils_Strings::tokenizeToArrayKeys("a,b , ,c", ",", true, false);
+ $this->assertEquals(4, count($sa));
+ $this->assertTrue($sa["a"] === true && $sa["b"] === true && $sa[""] === true && $sa["c"] === true, "components are not correct");
+
+ $sa = Bee_Utils_Strings::tokenizeToArrayKeys("a,b ,c", ",", false, true);
+ $this->assertEquals(3, count($sa));
+ $this->assertTrue($sa["a"] === true && $sa["b "] === true && $sa["c"] === true, "components are not correct");
+ }
+
+ /**
+ * @test
+ */
+ public function tokenizeToArray() {
+ $sa = Bee_Utils_Strings::tokenizeToArray("a,b , ,c", ",");
+ $this->assertEquals(3, count($sa));
+ $this->assertTrue($sa[0] === "a" && $sa[1] === "b" && $sa[2] === "c", "components are not correct");
+
+ $sa = Bee_Utils_Strings::tokenizeToArray("a,b , ,c", ",", true, false);
+ $this->assertEquals(4, count($sa));
+ $this->assertTrue($sa[0] === "a" && $sa[1] === "b" && $sa[2] === "" && $sa[3] === "c", "components are not correct");
+
+ $sa = Bee_Utils_Strings::tokenizeToArray("a,b ,c", ",", false, true);
+ $this->assertEquals(3, count($sa));
+ $this->assertTrue($sa[0] === "a" && $sa[1] === "b " && $sa[2] === "c", "components are not correct");
+ }
+
+ /**
+ * @test
+ */
+ public function startsWith() {
+ $this->assertTrue(Bee_Utils_Strings::startsWith(null, null));
+ $this->assertTrue(Bee_Utils_Strings::startsWith("", ""));
+
+ $this->assertFalse(Bee_Utils_Strings::startsWith("", null));
+ $this->assertFalse(Bee_Utils_Strings::startsWith("abcdef", null));
+ $this->assertFalse(Bee_Utils_Strings::startsWith(null, ""));
+ $this->assertFalse(Bee_Utils_Strings::startsWith(null, "a"));
+
+ $this->assertTrue(Bee_Utils_Strings::startsWith("abcdef", "a"));
+ $this->assertTrue(Bee_Utils_Strings::startsWith("abcdef", "ab"));
+ $this->assertTrue(Bee_Utils_Strings::startsWith("abcdef", ""));
+ $this->assertTrue(Bee_Utils_Strings::startsWith(" ", ""));
+
+ $this->assertFalse(Bee_Utils_Strings::startsWith("abcdef", "bcdef"));
+ $this->assertFalse(Bee_Utils_Strings::startsWith("abcdef", " "));
+ }
+
+ /**
+ * @test
+ * @expectedException Bee_Exceptions_TypeMismatch
+ */
+ public function startsWithSubjectNotString() {
+ Bee_Utils_Strings::startsWith(array(), "abcd");
+ }
+
+ /**
+ * @test
+ * @expectedException Bee_Exceptions_TypeMismatch
+ */
+ public function startsWithPrefixNotString() {
+ Bee_Utils_Strings::startsWith("abcd", array());
+ }
+
+ /**
+ * @test
+ */
+ public function stripPrefix() {
+ $this->assertEquals(null, Bee_Utils_Strings::stripPrefix(null, ''));
+ $this->assertEquals(null, Bee_Utils_Strings::stripPrefix(null, null));
+ $this->assertEquals('', Bee_Utils_Strings::stripPrefix('', ''));
+ $this->assertEquals('', Bee_Utils_Strings::stripPrefix('', null));
+
+ $this->assertEquals('abcdef', Bee_Utils_Strings::stripPrefix('abcdef', ''));
+ $this->assertEquals('abcdef', Bee_Utils_Strings::stripPrefix('abcdef', 'bcd'));
+ $this->assertEquals('abcdef', Bee_Utils_Strings::stripPrefix('abcdef', 'def'));
+ $this->assertEquals('abcdef', Bee_Utils_Strings::stripPrefix('abcdef', 'xyz'));
+
+ $this->assertEquals('', Bee_Utils_Strings::stripPrefix('', 'xyz'));
+
+ $this->assertEquals('def', Bee_Utils_Strings::stripPrefix('abcdef', 'abc'));
+ $this->assertEquals('beeframework.org/', Bee_Utils_Strings::stripPrefix('http://beeframework.org/', 'http://'));
+
+ }
+
+ /**
+ * @test
+ */
+ public function endsWith() {
+ $this->assertTrue(Bee_Utils_Strings::endsWith(null, null));
+ $this->assertTrue(Bee_Utils_Strings::endsWith("", ""));
+
+ $this->assertFalse(Bee_Utils_Strings::endsWith("", null));
+ $this->assertFalse(Bee_Utils_Strings::endsWith("abcdef", null));
+ $this->assertFalse(Bee_Utils_Strings::endsWith(null, ""));
+ $this->assertFalse(Bee_Utils_Strings::endsWith(null, "a"));
+
+ $this->assertTrue(Bee_Utils_Strings::endsWith("abcdef", "f"));
+ $this->assertTrue(Bee_Utils_Strings::endsWith("abcdef", "ef"));
+ $this->assertTrue(Bee_Utils_Strings::endsWith("abcdef", ""));
+ $this->assertTrue(Bee_Utils_Strings::endsWith(" ", ""));
+
+ $this->assertFalse(Bee_Utils_Strings::endsWith("abcdef", "abcde"));
+ $this->assertFalse(Bee_Utils_Strings::endsWith("abcdef", " "));
+ }
+
+ /**
+ * @test
+ * @expectedException Bee_Exceptions_TypeMismatch
+ */
+ public function endsWithSubjectNotString() {
+ Bee_Utils_Strings::endsWith(array(), "abcd");
+ }
+
+ /**
+ * @test
+ * @expectedException Bee_Exceptions_TypeMismatch
+ */
+ public function endsWithSuffixNotString() {
+ Bee_Utils_Strings::endsWith("abcd", array());
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/tests/Bee/Utils/StringsTest.php
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/tests/bootstrap.php
===================================================================
--- trunk/tests/bootstrap.php (rev 0)
+++ trunk/tests/bootstrap.php 2011-12-12 18:20:38 UTC (rev 11)
@@ -0,0 +1,27 @@
+<?php
+/*
+ * Copyright 2008-2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * User: mp
+ * Date: 01.07.11
+ * Time: 16:34
+ */
+
+require_once '../libs/addendum-0.4.1/annotations.php';
+require_once '../libs/log4php-2.1.0/Logger.php';
+require_once '../framework/potiscom/BeeFramework.php';
+
Property changes on: trunk/tests/bootstrap.php
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/tests/phpunit.xml
===================================================================
--- trunk/tests/phpunit.xml (rev 0)
+++ trunk/tests/phpunit.xml 2011-12-12 18:20:38 UTC (rev 11)
@@ -0,0 +1,8 @@
+<phpunit bootstrap="bootstrap.php"
+ colors="false"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ stopOnFailure="true">
+ <!-- ... -->
+</phpunit>
Property changes on: trunk/tests/phpunit.xml
___________________________________________________________________
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|