Skip to content

Commit

Permalink
Refactoring 'AcceptsString' to 'AcceptsList'.
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisJordan committed Jun 9, 2009
1 parent c8a5db9 commit 9cbc727
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions recess/recess/http/Accepts.class.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
Library::import('recess.http.AcceptsString');
Library::import('recess.http.AcceptsList');
Library::import('recess.http.MimeType');

class Accepts {
Expand Down Expand Up @@ -51,7 +51,7 @@ public function nextFormat() {
}

protected function initFormats() {
$this->types = new AcceptsString($this->headers[self::TYPES]);
$this->types = new AcceptsList($this->headers[self::TYPES]);
}

public function resetFormats() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

class AcceptsString {
class AcceptsList {

protected $range;

Expand Down
1 change: 1 addition & 0 deletions recess/test/recess/RecessAllTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require_once 'recess/lang/RecessLangAllTests.php';
require_once 'recess/framework/RecessFrameworkAllTests.php';
require_once 'recess/database/RecessDatabaseAllTests.php';
require_once 'recess/http/RecessHttpAllTests.php';

class RecessAllTests {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php
Library::import('recess.http.AcceptsString');
Library::import('recess.http.AcceptsList');

class AcceptsStringTest extends PHPUnit_Framework_TestCase {
class AcceptsListTest extends PHPUnit_Framework_TestCase {
protected $mediaString = 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5';
protected $media2String = 'image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/x-shockwave-flash, application/x-silverlight-2-b2, application/x-silverlight, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*';
protected $languageString = 'en-us,en;q=0.5';
protected $charsetString = 'ISO-8859-1,utf-8;q=0.7,*;q=0.7';
protected $specificityString = 'text/*,text/html,text/plain;q=0.9,text/*;q=0.9,*/*;q=0.9';

function testMediaString() {
$acceptsString = new AcceptsString($this->mediaString);
$acceptsString = new AcceptsList($this->mediaString);
$this->assertEquals(array('text/xml','application/xml','application/xhtml+xml','image/png'), $acceptsString->next());
$this->assertEquals(array('text/html'), $acceptsString->next());
$this->assertEquals(array('text/plain'), $acceptsString->next());
Expand All @@ -18,29 +18,29 @@ function testMediaString() {
}

function testMedia2String() {
$acceptsString = new AcceptsString($this->media2String);
$acceptsString = new AcceptsList($this->media2String);
$this->assertEquals(array('image/gif', 'image/jpeg', 'image/pjpeg', 'application/x-ms-application', 'application/vnd.ms-xpsdocument', 'application/xaml+xml', 'application/x-ms-xbap', 'application/x-shockwave-flash', 'application/x-silverlight-2-b2', 'application/x-silverlight', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', 'application/msword'), $acceptsString->next());
$this->assertEquals(array('*/*'), $acceptsString->next());
$this->assertEquals(false, $acceptsString->next());
}

function testLanguageString() {
$acceptsString = new AcceptsString($this->languageString);
$acceptsString = new AcceptsList($this->languageString);
$this->assertEquals(array('en-us'), $acceptsString->next());
$this->assertEquals(array('en'), $acceptsString->next());
$this->assertEquals(false, $acceptsString->next());
}

function testCharsetString() {
$acceptsString = new AcceptsString($this->charsetString);
$acceptsString = new AcceptsList($this->charsetString);
$this->assertEquals(array('ISO-8859-1'), $acceptsString->next());
$this->assertEquals(array('utf-8'), $acceptsString->next());
$this->assertEquals(array('*'), $acceptsString->next());
$this->assertEquals(false, $acceptsString->next());
}

function testSpecificity() {
$acceptsString = new AcceptsString($this->specificityString);
$acceptsString = new AcceptsList($this->specificityString);
$this->assertEquals(array('text/html'), $acceptsString->next());
$this->assertEquals(array('text/*'), $acceptsString->next());
$this->assertEquals(array('text/plain'), $acceptsString->next());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
require_once 'PHPUnit/Framework.php';
require_once 'recess/http/AcceptsTest.php';
require_once 'recess/http/AcceptsStringTest.php';
require_once 'recess/http/AcceptsListTest.php';

class RecessHttpAllTests
{
Expand All @@ -10,7 +10,7 @@ public static function suite()
$suite = new PHPUnit_Framework_TestSuite('recess.http');

$suite->addTestSuite('AcceptsTest');
$suite->addTestSuite('AcceptsStringTest');
$suite->addTestSuite('AcceptsListTest');

return $suite;
}
Expand Down

0 comments on commit 9cbc727

Please sign in to comment.