2
0
فهرست منبع

ZF-8720 - fixed issue with removing exclamation mark from location string

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@20097 44c647ce-9c0f-0410-b52a-842ac1e357ba
bate 16 سال پیش
والد
کامیت
6b9be5a63b
2فایلهای تغییر یافته به همراه53 افزوده شده و 1 حذف شده
  1. 1 1
      library/Zend/Gdata/YouTube/VideoQuery.php
  2. 52 0
      tests/Zend/Gdata/YouTube/VideoQueryTest.php

+ 1 - 1
library/Zend/Gdata/YouTube/VideoQuery.php

@@ -140,7 +140,7 @@ class Zend_Gdata_YouTube_VideoQuery extends Zend_Gdata_Query
                     $temp = trim($param);
                     // strip off the optional exclamation mark for numeric check
                     if (substr($temp, -1) == '!') {
-                        $temp = substr($temp, -1);
+                        $temp = substr($temp, 0, -1);
                     }
                     if (!is_numeric($temp)) {
                         require_once 'Zend/Gdata/App/InvalidArgumentException.php';

+ 52 - 0
tests/Zend/Gdata/YouTube/VideoQueryTest.php

@@ -163,4 +163,56 @@ class Zend_Gdata_YouTube_VideoQueryTest extends PHPUnit_Framework_TestCase
             'safeSearch.');
     }
 
+    /**
+     * @group ZF-8720
+     * @expectedException Zend_Gdata_App_InvalidArgumentException
+     */
+    public function testVideoQuerySetLocationException()
+    {
+        $yt = new Zend_Gdata_YouTube();
+        $query = $yt->newVideoQuery();
+        $location = 'foobar';
+        $this->assertNull($query->setLocation($location));
+    }
+
+    /**
+     * @group ZF-8720
+     * @expectedException Zend_Gdata_App_InvalidArgumentException
+     */
+    public function testVideoQuerySetLocationExceptionV2()
+    {
+        $yt = new Zend_Gdata_YouTube();
+        $query = $yt->newVideoQuery();
+        $location = '-100x,-200y';
+        $this->assertNull($query->setLocation($location));
+    }
+
+    /**
+     * @group ZF-8720
+     * @expectedException Zend_Gdata_App_InvalidArgumentException
+     */
+    public function testVideoQuerySetLocationExceptionV3()
+    {
+        $yt = new Zend_Gdata_YouTube();
+        $query = $yt->newVideoQuery();
+        $location = '-100x,-200y!';
+        $this->assertNull($query->setLocation($location));
+    }
+
+    /**
+     * @group ZF-8720
+     */
+    public function testQueryExclamationMarkRemoveBug()
+    {
+        $yt = new Zend_Gdata_YouTube();
+        $query = $yt->newVideoQuery();
+
+        $location = '37.42307,-122.08427';
+        $this->assertNull($query->setLocation($location));
+        $this->assertEquals($location, $query->getLocation());
+
+        $location = '37.42307,-122.08427!';
+        $this->assertNull($query->setLocation($location));
+        $this->assertEquals($location, $query->getLocation());
+    }
 }