code
stringlengths 31
1.39M
| docstring
stringlengths 23
16.8k
| func_name
stringlengths 1
126
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
166
| url
stringlengths 50
220
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
function testPostal() {
$this->assertFalse(Validation::postal('111', null, 'de'));
$this->assertFalse(Validation::postal('1111', null, 'de'));
$this->assertTrue(Validation::postal('13089', null, 'de'));
$this->assertFalse(Validation::postal('111', null, 'be'));
$this->assertFalse(Validation::postal('0123', null, 'be'));
$this->assertTrue(Validation::postal('1204', null, 'be'));
$this->assertFalse(Validation::postal('111', null, 'it'));
$this->assertFalse(Validation::postal('1111', null, 'it'));
$this->assertTrue(Validation::postal('13089', null, 'it'));
$this->assertFalse(Validation::postal('111', null, 'uk'));
$this->assertFalse(Validation::postal('1111', null, 'uk'));
$this->assertFalse(Validation::postal('AZA 0AB', null, 'uk'));
$this->assertFalse(Validation::postal('X0A 0ABC', null, 'uk'));
$this->assertTrue(Validation::postal('X0A 0AB', null, 'uk'));
$this->assertTrue(Validation::postal('AZ0A 0AA', null, 'uk'));
$this->assertTrue(Validation::postal('A89 2DD', null, 'uk'));
$this->assertFalse(Validation::postal('111', null, 'ca'));
$this->assertFalse(Validation::postal('1111', null, 'ca'));
$this->assertFalse(Validation::postal('D2A 0A0', null, 'ca'));
$this->assertFalse(Validation::postal('BAA 0ABC', null, 'ca'));
$this->assertFalse(Validation::postal('B2A AABC', null, 'ca'));
$this->assertFalse(Validation::postal('B2A 2AB', null, 'ca'));
$this->assertTrue(Validation::postal('X0A 0A2', null, 'ca'));
$this->assertTrue(Validation::postal('G4V 4C3', null, 'ca'));
$this->assertTrue(Validation::postal('L4J8D6', null, 'ca'));
$this->assertFalse(Validation::postal('111', null, 'us'));
$this->assertFalse(Validation::postal('1111', null, 'us'));
$this->assertFalse(Validation::postal('130896', null, 'us'));
$this->assertFalse(Validation::postal('13089-33333', null, 'us'));
$this->assertFalse(Validation::postal('13089-333', null, 'us'));
$this->assertFalse(Validation::postal('13A89-4333', null, 'us'));
$this->assertTrue(Validation::postal('13089-3333', null, 'us'));
$this->assertFalse(Validation::postal('111'));
$this->assertFalse(Validation::postal('1111'));
$this->assertFalse(Validation::postal('130896'));
$this->assertFalse(Validation::postal('13089-33333'));
$this->assertFalse(Validation::postal('13089-333'));
$this->assertFalse(Validation::postal('13A89-4333'));
$this->assertTrue(Validation::postal('13089-3333'));
} | testPostal method
@access public
@return void | testPostal | php | Datawalke/Coordino | cake/tests/cases/libs/validation.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/validation.test.php | MIT |
function testPhonePostalSsnPass() {
$this->assertTrue(Validation::postal('text', null, 'testNl'));
$this->assertTrue(Validation::phone('text', null, 'testDe'));
$this->assertTrue(Validation::ssn('text', null, 'testNl'));
} | test that phone and postal pass to other classes.
@return void | testPhonePostalSsnPass | php | Datawalke/Coordino | cake/tests/cases/libs/validation.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/validation.test.php | MIT |
function testPassThroughMethod() {
$this->assertTrue(Validation::postal('text', null, 'testNl'));
$this->expectError('Could not find AUTOFAILValidation class, unable to complete validation.');
Validation::postal('text', null, 'AUTOFAIL');
$this->expectError('Method phone does not exist on TestNlValidation unable to complete validation.');
Validation::phone('text', null, 'testNl');
} | test the pass through calling of an alternate locale with postal()
@return void | testPassThroughMethod | php | Datawalke/Coordino | cake/tests/cases/libs/validation.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/validation.test.php | MIT |
function testSsn() {
$this->assertFalse(Validation::ssn('111-333', null, 'dk'));
$this->assertFalse(Validation::ssn('111111-333', null, 'dk'));
$this->assertTrue(Validation::ssn('111111-3334', null, 'dk'));
$this->assertFalse(Validation::ssn('1118333', null, 'nl'));
$this->assertFalse(Validation::ssn('1234567890', null, 'nl'));
$this->assertFalse(Validation::ssn('12345A789', null, 'nl'));
$this->assertTrue(Validation::ssn('123456789', null, 'nl'));
$this->assertFalse(Validation::ssn('11-33-4333', null, 'us'));
$this->assertFalse(Validation::ssn('113-3-4333', null, 'us'));
$this->assertFalse(Validation::ssn('111-33-333', null, 'us'));
$this->assertTrue(Validation::ssn('111-33-4333', null, 'us'));
} | testSsn method
@access public
@return void | testSsn | php | Datawalke/Coordino | cake/tests/cases/libs/validation.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/validation.test.php | MIT |
function testUserDefined() {
$validator = new CustomValidator;
$this->assertFalse(Validation::userDefined('33', $validator, 'customValidate'));
$this->assertFalse(Validation::userDefined('3333', $validator, 'customValidate'));
$this->assertTrue(Validation::userDefined('333', $validator, 'customValidate'));
} | testUserDefined method
@access public
@return void | testUserDefined | php | Datawalke/Coordino | cake/tests/cases/libs/validation.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/validation.test.php | MIT |
function setUp() {
$manager =& new XmlManager();
$manager->namespaces = array();
} | setUp method
@access public
@return void | setUp | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testRootTagParsing() {
$input = '<' . '?xml version="1.0" encoding="UTF-8" ?' . '>' . "\n" .
'<plugin id="1" version_id="1" name="my_plugin" title="My Plugin" author="Me" author_email="[email protected]" description="My awesome package" created="2008-01-28 18:21:13" updated="2008-01-28 18:21:13">'
.'<current id="1" plugin_id="1" name="1.0" file="" created="2008-01-28 18:21:13" updated="2008-01-28 18:21:13" />'
.'<version id="1" plugin_id="1" name="1.0" file="" created="2008-01-28 18:21:13" updated="2008-01-28 18:21:13" />'
.'</plugin>';
$xml = new Xml($input);
$this->assertEqual($xml->children[0]->name, 'plugin');
$this->assertEqual($xml->children[0]->children[0]->name, 'current');
$this->assertEqual($xml->toString(true), $input);
} | testRootTagParsing method
@access public
@return void | testRootTagParsing | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testSerialization() {
$input = array(
array(
'Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 1, 'industry_id' => 1, 'modified' => null, 'created' => null),
'Style' => array('id' => null, 'name' => null),
'JobType' => array('id' => 1, 'name' => 'Touch Screen Kiosk'),
'Industry' => array('id' => 1, 'name' => 'Financial')
),
array(
'Project' => array('id' => 2, 'title' => null, 'client_id' => 2, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 2, 'industry_id' => 2, 'modified' => '2007-11-26 14:48:36', 'created' => null),
'Style' => array('id' => null, 'name' => null),
'JobType' => array('id' => 2, 'name' => 'Awareness Campaign'),
'Industry' => array('id' => 2, 'name' => 'Education')
)
);
$xml = new Xml($input);
$result = preg_replace("/\n/",'', $xml->toString(false));
$expected = '<project id="1" title="" client_id="1" show="1" is_spotlight="" style_id="0" job_type_id="1" industry_id="1" modified="" created=""><style id="" name="" /><job_type id="1" name="Touch Screen Kiosk" /><industry id="1" name="Financial" /></project><project id="2" title="" client_id="2" show="1" is_spotlight="" style_id="0" job_type_id="2" industry_id="2" modified="2007-11-26 14:48:36" created=""><style id="" name="" /><job_type id="2" name="Awareness Campaign" /><industry id="2" name="Education" /></project>';
$this->assertEqual($result, $expected);
$input = array(
'Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 1, 'industry_id' => 1, 'modified' => null, 'created' => null),
'Style' => array('id' => null, 'name' => null),
'JobType' => array('id' => 1, 'name' => 'Touch Screen Kiosk'),
'Industry' => array('id' => 1, 'name' => 'Financial')
);
$expected = '<project id="1" title="" client_id="1" show="1" is_spotlight="" style_id="0" job_type_id="1" industry_id="1" modified="" created=""><style id="" name="" /><job_type id="1" name="Touch Screen Kiosk" /><industry id="1" name="Financial" /></project>';
$xml = new Xml($input);
$result = preg_replace("/\n/",'', $xml->toString(false));
$this->assertEqual($result, $expected);
} | testSerialization method
@access public
@return void | testSerialization | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testSerializeOnMultiDimensionalArray() {
$data = array(
'Statuses' => array(
array('Status' => array('id' => 1)),
array('Status' => array('id' => 2))
)
);
$result =& new Xml($data, array('format' => 'tags'));
$expected = '<statuses><status><id>1</id></status><status><id>2</id></status></statuses>';
$this->assertIdentical($result->toString(), $expected);
} | testSerializeOnMultiDimensionalArray method
@access public
@return void | testSerializeOnMultiDimensionalArray | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testSerializeCapsWithoutSlug() {
$data = array(
'USERS' => array(
array('USER' => array('ID' => 1)),
array('USER' => array('ID' => 2))
)
);
$result =& new Xml($data, array('format' => 'tags', 'slug' => false));
$expected = '<USERS><USER><ID>1</ID></USER><USER><ID>2</ID></USER></USERS>';
$this->assertIdentical($result->toString(), $expected);
} | testSerializeCapsWithoutSlug method
@access public
@return void | testSerializeCapsWithoutSlug | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testSerializationOfBooleanAndBooleanishValues() {
$xml =& new Xml(array('data' => array('example' => false)));
$result = $xml->toString(false);
$expected = '<data example="0" />';
$this->assertEqual($result, $expected, 'Boolean values incorrectly handled. %s');
$xml =& new Xml(array('data' => array('example' => true)));
$result = $xml->toString(false);
$expected = '<data example="1" />';
$this->assertEqual($result, $expected, 'Boolean values incorrectly handled. %s');
$xml =& new Xml(array('data' => array('example' => null)));
$result = $xml->toString(false);
$expected = '<data example="" />';
$this->assertEqual($result, $expected, 'Boolean values incorrectly handled. %s');
$xml =& new Xml(array('data' => array('example' => 0)));
$result = $xml->toString(false);
$expected = '<data example="0" />';
$this->assertEqual($result, $expected, 'Boolean-ish values incorrectly handled. %s');
$xml =& new Xml(array('data' => array('example' => 1)));
$result = $xml->toString(false);
$expected = '<data example="1" />';
$this->assertEqual($result, $expected, 'Boolean-ish values incorrectly handled. %s');
} | test serialization of boolean and null values. false = 0, true = 1, null = ''
@return void | testSerializationOfBooleanAndBooleanishValues | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testSimpleArray() {
$xml = new Xml(array('hello' => 'world'), array('format' => 'tags'));
$result = $xml->toString(false);
$expected = '<hello><![CDATA[world]]></hello>';
$this->assertEqual($expected, $result);
} | testSimpleArray method
@access public
@return void | testSimpleArray | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testSimpleObject() {
$input = new StdClass();
$input->hello = 'world';
$xml = new Xml($input, array('format' => 'tags'));
$result = $xml->toString(false);
$expected = '<hello><![CDATA[world]]></hello>';
$this->assertEqual($expected, $result);
} | testSimpleObject method
@access public
@return void | testSimpleObject | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testSimpleArrayWithZeroValues() {
$xml = new Xml(array('zero_string' => '0', 'zero_integer' => 0), array('format' => 'tags'));
$result = $xml->toString(false);
$expected = '<zero_string>0</zero_string><zero_integer>0</zero_integer>';
$this->assertEqual($expected, $result);
$data = array(
'Client' => array(
'id' => 3,
'object_id' => 9,
'key' => 'alt',
'name' => 'Client Two',
'created_by' => 4,
'status' => '0',
'num_projects' => 0
)
);
$xml = new Xml($data, array('format' => 'tags'));
$result = $xml->toString(array('format' => 'tags', 'header' => false));
$this->assertPattern('/<status>0<\/status>/', $result);
$this->assertPattern('/<num_projects>0<\/num_projects>/', $result);
} | testSimpleArrayWithZeroValues method
@access public
@return void | testSimpleArrayWithZeroValues | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testHeader() {
$input = new stdClass();
$input->hello = 'world';
$xml = new Xml($input, array('format' => 'tags'));
$result = $xml->toString(array('header' => true));
$expected = '<'.'?xml version="1.0" encoding="UTF-8" ?'.'>'."\n".'<hello><![CDATA[world]]></hello>';
$this->assertEqual($expected, $result);
} | testHeader method
@access public
@return void | testHeader | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testOwnerAssignment() {
$xml = new Xml();
$node =& $xml->createElement('hello', 'world');
$owner =& $node->document();
$this->assertTrue($xml === $owner);
$children =& $node->children;
$childOwner =& $children[0]->document();
$this->assertTrue($xml === $childOwner);
} | testOwnerAssignment method
@access public
@return void | testOwnerAssignment | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testArraySingleSerialization() {
$input = array(
'Post' => array(
'id' => '1', 'author_id' => '1', 'title' => 'First Post',
'body' => 'First Post Body', 'published' => 'Y',
'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
),
'Author' => array(
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', 'test' => 'working'
)
);
$expected = '<post><id>1</id><author_id>1</author_id><title><![CDATA[First Post]]>';
$expected .= '</title><body><![CDATA[First Post Body]]></body><published><![CDATA[Y]]>';
$expected .= '</published><created><![CDATA[2007-03-18 10:39:23]]></created><updated>';
$expected .= '<![CDATA[2007-03-18 10:41:31]]></updated><author><id>1</id><user>';
$expected .= '<![CDATA[mariano]]></user><password><![CDATA[5f4dcc3b5aa765d61d8327deb882';
$expected .= 'cf99]]></password><created><![CDATA[2007-03-17 01:16:23]]></created>';
$expected .= '<updated><![CDATA[2007-03-17 01:18:31]]></updated><test><![CDATA[working]]>';
$expected .= '</test></author></post>';
$xml = new Xml($input, array('format' => 'tags'));
$result = $xml->toString(false);
$this->assertEqual($expected, $result);
} | testArraySingleSerialization method
@access public
@return void | testArraySingleSerialization | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testSerializationArray() {
$input = array(
array(
'Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 1, 'industry_id' => 1, 'modified' => null, 'created' => null),
'Style' => array('id' => null, 'name' => null),
'JobType' => array('id' => 1, 'name' => 'Touch Screen Kiosk'),
'Industry' => array('id' => 1, 'name' => 'Financial')
),
array(
'Project' => array('id' => 2, 'title' => null, 'client_id' => 2, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 2, 'industry_id' => 2, 'modified' => '2007-11-26 14:48:36', 'created' => null),
'Style' => array('id' => null, 'name' => null),
'JobType' => array('id' => 2, 'name' => 'Awareness Campaign'),
'Industry' => array('id' => 2, 'name' => 'Education'),
)
);
$expected = '<project><id>1</id><title /><client_id>1</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>1</job_type_id><industry_id>1</industry_id><modified /><created /><style><id /><name /></style><job_type><id>1</id><name>Touch Screen Kiosk</name></job_type><industry><id>1</id><name>Financial</name></industry></project><project><id>2</id><title /><client_id>2</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>2</job_type_id><industry_id>2</industry_id><modified>2007-11-26 14:48:36</modified><created /><style><id /><name /></style><job_type><id>2</id><name>Awareness Campaign</name></job_type><industry><id>2</id><name>Education</name></industry></project>';
$xml = new Xml($input, array('format' => 'tags'));
$result = $xml->toString(array('header' => false, 'cdata' => false));
$this->assertEqual($expected, $result);
} | testArraySerialization method
@access public
@return void | testSerializationArray | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testSerializationNestedArray() {
$input = array(
array(
'Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 1, 'industry_id' => 1, 'modified' => null, 'created' => null),
'Style' => array('id' => null, 'name' => null),
'JobType' => array('id' => 1, 'name' => 'Touch Screen Kiosk'),
'Industry' => array('id' => 1, 'name' => 'Financial'),
'BusinessSolution' => array(array('id' => 6, 'name' => 'Convert Sales')),
'MediaType' => array(
array('id' => 15, 'name' => 'Print'),
array('id' => 7, 'name' => 'Web Demo'),
array('id' => 6, 'name' => 'CD-ROM')
)
),
array(
'Project' => array('id' => 2, 'title' => null, 'client_id' => 2, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 2, 'industry_id' => 2, 'modified' => '2007-11-26 14:48:36', 'created' => null),
'Style' => array('id' => null, 'name' => null),
'JobType' => array('id' => 2, 'name' => 'Awareness Campaign'),
'Industry' => array('id' => 2, 'name' => 'Education'),
'BusinessSolution' => array(
array('id' => 4, 'name' => 'Build Relationship'),
array('id' => 6, 'name' => 'Convert Sales')
),
'MediaType' => array(
array('id' => 17, 'name' => 'Web'),
array('id' => 6, 'name' => 'CD-ROM')
)
)
);
$expected = '<project><id>1</id><title /><client_id>1</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>1</job_type_id><industry_id>1</industry_id><modified /><created /><style><id /><name /></style><job_type><id>1</id><name>Touch Screen Kiosk</name></job_type><industry><id>1</id><name>Financial</name></industry><business_solution><id>6</id><name>Convert Sales</name></business_solution><media_type><id>15</id><name>Print</name></media_type><media_type><id>7</id><name>Web Demo</name></media_type><media_type><id>6</id><name>CD-ROM</name></media_type></project><project><id>2</id><title /><client_id>2</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>2</job_type_id><industry_id>2</industry_id><modified>2007-11-26 14:48:36</modified><created /><style><id /><name /></style><job_type><id>2</id><name>Awareness Campaign</name></job_type><industry><id>2</id><name>Education</name></industry><business_solution><id>4</id><name>Build Relationship</name></business_solution><business_solution><id>6</id><name>Convert Sales</name></business_solution><media_type><id>17</id><name>Web</name></media_type><media_type><id>6</id><name>CD-ROM</name></media_type></project>';
$xml = new Xml($input, array('format' => 'tags'));
$result = $xml->toString(array('header' => false, 'cdata' => false));
$this->assertEqual($expected, $result);
} | testNestedArraySerialization method
@access public
@return void | testSerializationNestedArray | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testArraySerializationWithRoot() {
$input = array(
array('Shirt' => array('id' => 1, 'color' => 'green')),
array('Shirt' => array('id' => 2, 'color' => 'blue')),
);
$expected = '<collection><shirt id="1" color="green" />';
$expected .= '<shirt id="2" color="blue" /></collection>';
$Xml = new Xml($input, array('root' => 'collection'));
$result = $Xml->toString(array('header' => false));
$this->assertEqual($expected, $result);
} | Prove that serialization with a given root node works
as expected.
@access public
@return void
@link https://trac.cakephp.org/ticket/6294 | testArraySerializationWithRoot | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testParsingWithNonStandardWhitespace() {
$raw = '<?xml version="1.0" encoding="ISO-8859-1" ?><prices><price>1.0</price></prices>';
$array = array('Prices' => array('price' => 1.0));
$xml = new Xml($raw);
$this->assertEqual($xml->toArray(), $array);
$this->assertEqual($xml->__header, 'xml version="1.0" encoding="ISO-8859-1"');
$xml = new Xml(' ' . $raw);
$this->assertEqual($xml->toArray(), $array);
$this->assertEqual($xml->__header, 'xml version="1.0" encoding="ISO-8859-1"');
$xml = new Xml("\n" . $raw);
$this->assertEqual($xml->toArray(), $array);
$this->assertEqual($xml->__header, 'xml version="1.0" encoding="ISO-8859-1"');
} | Tests that XML documents with non-standard spacing (i.e. leading whitespace, whole document
on one line) still parse properly.
@return void | testParsingWithNonStandardWhitespace | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testAllCData() {
$input = array(
array(
'Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => '1', 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => '1.89', 'industry_id' => '1.56', 'modified' => null, 'created' => null),
'Style' => array('id' => null, 'name' => null),
'JobType' => array('id' => 1, 'name' => 'Touch Screen Kiosk'),
'Industry' => array('id' => 1, 'name' => 'Financial')
),
array(
'Project' => array('id' => 2, 'title' => null, 'client_id' => 2, 'show' => '1', 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => '2.2', 'industry_id' => 2.2, 'modified' => '2007-11-26 14:48:36', 'created' => null),
'Style' => array('id' => null, 'name' => null),
'JobType' => array('id' => 2, 'name' => 'Awareness Campaign'),
'Industry' => array('id' => 2, 'name' => 'Education'),
)
);
$expected = '<project><id>1</id><title /><client_id>1</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>1.89</job_type_id><industry_id>1.56</industry_id><modified /><created /><style><id /><name /></style><job_type><id>1</id><name><![CDATA[Touch Screen Kiosk]]></name></job_type><industry><id>1</id><name><![CDATA[Financial]]></name></industry></project><project><id>2</id><title /><client_id>2</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>2.2</job_type_id><industry_id>2.2</industry_id><modified><![CDATA[2007-11-26 14:48:36]]></modified><created /><style><id /><name /></style><job_type><id>2</id><name><![CDATA[Awareness Campaign]]></name></job_type><industry><id>2</id><name><![CDATA[Education]]></name></industry></project>';
$xml = new Xml($input, array('format' => 'tags'));
$result = $xml->toString(array('header' => false, 'cdata' => true));
$this->assertEqual($expected, $result);
} | testAllCData method
@access public
@return void | testAllCData | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testWhitespace() {
$input = array(
array(
'Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 1, 'industry_id' => 1, 'modified' => null, 'created' => null),
'Style' => array('id' => null, 'name' => null),
'JobType' => array('id' => 1, 'name' => 'Touch Screen Kiosk'),
'Industry' => array('id' => 1, 'name' => 'Financial')
),
array(
'Project' => array('id' => 2, 'title' => null, 'client_id' => 2, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 2, 'industry_id' => 2, 'modified' => '2007-11-26 14:48:36', 'created' => null),
'Style' => array('id' => null, 'name' => null),
'JobType' => array('id' => 2, 'name' => 'Awareness Campaign'),
'Industry' => array('id' => 2, 'name' => 'Education'),
)
);
$expected = "\n\t<project>\n\t\t<id>\n\t\t\t1\n\t\t</id>\n\t\t<title />\n\t\t<client_id>\n\t\t\t1\n\t\t</client_id>\n\t\t<show>\n\t\t\t1\n\t\t</show>\n\t\t<is_spotlight />\n\t\t<style_id>\n\t\t\t0\n\t\t</style_id>\n\t\t<job_type_id>\n\t\t\t1\n\t\t</job_type_id>\n\t\t<industry_id>\n\t\t\t1\n\t\t</industry_id>\n\t\t<modified />\n\t\t<created />\n\t\t<style>\n\t\t\t<id />\n\t\t\t<name />\n\t\t</style>\n\t\t<job_type>\n\t\t\t<id>\n\t\t\t\t1\n\t\t\t</id>\n\t\t\t<name>\n\t\t\t\tTouch Screen Kiosk\n\t\t\t</name>\n\t\t</job_type>\n\t\t<industry>\n\t\t\t<id>\n\t\t\t\t1\n\t\t\t</id>\n\t\t\t<name>\n\t\t\t\tFinancial\n\t\t\t</name>\n\t\t</industry>\n\t</project>\n\t<project>\n\t\t<id>\n\t\t\t2\n\t\t</id>\n\t\t<title />\n\t\t<client_id>\n\t\t\t2\n\t\t</client_id>\n\t\t<show>\n\t\t\t1\n\t\t</show>\n\t\t<is_spotlight />\n\t\t<style_id>\n\t\t\t0\n\t\t</style_id>\n\t\t<job_type_id>\n\t\t\t2\n\t\t</job_type_id>\n\t\t<industry_id>\n\t\t\t2\n\t\t</industry_id>\n\t\t<modified>\n\t\t\t2007-11-26 14:48:36\n\t\t</modified>\n\t\t<created />\n\t\t<style>\n\t\t\t<id />\n\t\t\t<name />\n\t\t</style>\n\t\t<job_type>\n\t\t\t<id>\n\t\t\t\t2\n\t\t\t</id>\n\t\t\t<name>\n\t\t\t\tAwareness Campaign\n\t\t\t</name>\n\t\t</job_type>\n\t\t<industry>\n\t\t\t<id>\n\t\t\t\t2\n\t\t\t</id>\n\t\t\t<name>\n\t\t\t\tEducation\n\t\t\t</name>\n\t\t</industry>\n\t</project>\n";
$xml = new Xml($input, array('format' => 'tags'));
$result = $xml->toString(array('header' => false, 'cdata' => false, 'whitespace' => true));
$this->assertEqual($expected, $result);
} | testWhitespace method
@access public
@return void | testWhitespace | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testSetSerialization() {
$input = array(
array(
'Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 1, 'industry_id' => 1, 'modified' => null, 'created' => null),
'Style' => array('id' => null, 'name' => null),
'JobType' => array('id' => 1, 'name' => 'Touch Screen Kiosk'),
'Industry' => array('id' => 1, 'name' => 'Financial')
),
array(
'Project' => array('id' => 2, 'title' => null, 'client_id' => 2, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 2, 'industry_id' => 2, 'modified' => '2007-11-26 14:48:36', 'created' => null),
'Style' => array('id' => null, 'name' => null),
'JobType' => array('id' => 2, 'name' => 'Awareness Campaign'),
'Industry' => array('id' => 2, 'name' => 'Education'),
)
);
$expected = '<project><id>1</id><title /><client_id>1</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>1</job_type_id><industry_id>1</industry_id><modified /><created /><style><id /><name /></style><job_type><id>1</id><name>Touch Screen Kiosk</name></job_type><industry><id>1</id><name>Financial</name></industry></project><project><id>2</id><title /><client_id>2</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>2</job_type_id><industry_id>2</industry_id><modified>2007-11-26 14:48:36</modified><created /><style><id /><name /></style><job_type><id>2</id><name>Awareness Campaign</name></job_type><industry><id>2</id><name>Education</name></industry></project>';
$xml = new Xml(Set::map($input), array('format' => 'tags'));
$result = $xml->toString(array('header' => false, 'cdata' => false));
$this->assertEqual($expected, $result);
} | testSetSerialization method
@access public
@return void | testSetSerialization | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testNormalizeNotAdding_name_Element() {
$input = array(
'output' => array(
'Vouchers' => array(
array('Voucher' => array('id' => 1)),
array('Voucher' => array('id' => 2)),
),
)
);
$xml = new Xml($input, array('attributes' => false, 'format' => 'tags'));
$this->assertFalse(isset($xml->children[0]->children[0]->children[1]), 'Too many children %s');
$this->assertEqual($xml->children[0]->children[0]->children[0]->name, 'voucher');
} | ensure that normalize does not add _name_ elements that come from Set::map sometimes.
@return void | testNormalizeNotAdding_name_Element | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testSimpleParsing() {
$source = '<response><hello><![CDATA[happy world]]></hello><goodbye><![CDATA[cruel world]]></goodbye></response>';
$xml = new Xml($source);
$result = $xml->toString();
$this->assertEqual($source, $result);
} | testSimpleParsing method
@access public
@return void | testSimpleParsing | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testElementCollapsing() {
$xmlDataThatFails = '<resultpackage>
<result qid="46b1c46ed6208"><![CDATA[46b1c46ed3af9]]></result>
<result qid="46b1c46ed332a"><![CDATA[]]></result>
<result qid="46b1c46ed90e6"><![CDATA[46b1c46ed69d8]]></result>
<result qid="46b1c46ed71a7"><![CDATA[46b1c46ed5a38]]></result>
<result qid="46b1c46ed8146"><![CDATA[46b1c46ed98b6]]></result>
<result qid="46b1c46ed7978"><![CDATA[]]></result>
<result qid="46b1c46ed4a98"><![CDATA[]]></result>
<result qid="46b1c46ed42c8"><![CDATA[]]></result>
<result qid="46b1c46ed5268"><![CDATA[46b1c46ed8917]]></result>
</resultpackage>';
$Xml = new Xml();
$Xml->load('<?xml version="1.0" encoding="UTF-8" ?>' . $xmlDataThatFails);
$result = $Xml->toArray(false);
$this->assertTrue(is_array($result));
$expected = array(
'resultpackage' => array(
'result' => array(
0 => array(
'value' => '46b1c46ed3af9',
'qid' => '46b1c46ed6208'),
1 => array(
'qid' => '46b1c46ed332a'),
2 => array(
'value' => '46b1c46ed69d8',
'qid' => '46b1c46ed90e6'),
3 => array(
'value' => '46b1c46ed5a38',
'qid' => '46b1c46ed71a7'),
4 => array(
'value' => '46b1c46ed98b6',
'qid' => '46b1c46ed8146'),
5 => array(
'qid' => '46b1c46ed7978'),
6 => array(
'qid' => '46b1c46ed4a98'),
7 => array(
'qid' => '46b1c46ed42c8'),
8 => array(
'value' => '46b1c46ed8917',
'qid' => '46b1c46ed5268'),
)
));
$this->assertEqual(
count($result['resultpackage']['result']), count($expected['resultpackage']['result']),
'Incorrect array length %s');
$this->assertFalse(
isset($result['resultpackage']['result'][0][0]['qid']), 'Nested array exists, data is corrupt. %s');
$this->assertEqual($result, $expected);
} | test that elements with empty tag values do not collapse and corrupt data structures
@access public
@return void | testElementCollapsing | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testCaseFoldingWithEmptyValues() {
$filledValue = '<method name="set_user_settings">
<title>update user information</title>
<user>1</user>
<User>
<id>1</id>
<name>varchar(45)</name>
</User>
</method>';
$xml =& new XML($filledValue);
$expected = array(
'Method' => array(
'name' => 'set_user_settings',
'title' => 'update user information',
'user' => '1',
'User' => array(
'id' => 1,
'name' => 'varchar(45)',
),
)
);
$result = $xml->toArray();
$this->assertEqual($result, $expected);
$emptyValue ='<method name="set_user_settings">
<title>update user information</title>
<user></user>
<User>
<id>1</id>
<name>varchar(45)</name>
</User>
</method>';
$xml =& new XML($emptyValue);
$expected = array(
'Method' => array(
'name' => 'set_user_settings',
'title' => 'update user information',
'user' => array(),
'User' => array(
'id' => 1,
'name' => 'varchar(45)',
),
)
);
$result = $xml->toArray();
$this->assertEqual($result, $expected);
} | test that empty values do not casefold collapse
@see http://code.cakephp.org/tickets/view/8
@return void | testCaseFoldingWithEmptyValues | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testMixedParsing() {
$source = '<response><body><hello><![CDATA[happy world]]></hello><![CDATA[in between]]><goodbye><![CDATA[cruel world]]></goodbye></body></response>';
$xml = new Xml($source);
$result = $xml->toString();
$this->assertEqual($source, $result);
} | testMixedParsing method
@access public
@return void | testMixedParsing | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testComplexParsing() {
$source = '<projects><project><id>1</id><title /><client_id>1</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>1</job_type_id><industry_id>1</industry_id><modified /><created /><style><id /><name /></style><job_type><id>1</id><name>Touch Screen Kiosk</name></job_type><industry><id>1</id><name>Financial</name></industry></project><project><id>2</id><title /><client_id>2</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>2</job_type_id><industry_id>2</industry_id><modified>2007-11-26 14:48:36</modified><created /><style><id /><name /></style><job_type><id>2</id><name>Awareness Campaign</name></job_type><industry><id>2</id><name>Education</name></industry></project></projects>';
$xml = new Xml($source);
$result = $xml->toString(array('cdata' => false));
$this->assertEqual($source, $result);
} | testComplexParsing method
@access public
@return void | testComplexParsing | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testNamespaceParsing() {
$source = '<a:container xmlns:a="http://example.com/a" xmlns:b="http://example.com/b" xmlns:c="http://example.com/c" xmlns:d="http://example.com/d" xmlns:e="http://example.com/e"><b:rule test=""><c:result>value</c:result></b:rule><d:rule test=""><e:result>value</e:result></d:rule></a:container>';
$xml = new Xml($source);
$result = $xml->toString(array('cdata' => false));
$this->assertEqual($source, $result);
$children = $xml->children('container');
$this->assertEqual($children[0]->namespace, 'a');
$children = $children[0]->children('rule');
$this->assertEqual($children[0]->namespace, 'b');
} | testNamespaceParsing method
@access public
@return void | testNamespaceParsing | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testNamespaces() {
$source = '<a:container xmlns:a="http://example.com/a" xmlns:b="http://example.com/b" xmlns:c="http://example.com/c" xmlns:d="http://example.com/d" xmlns:e="http://example.com/e"><b:rule test=""><c:result>value</c:result></b:rule><d:rule test=""><e:result>value</e:result></d:rule></a:container>';
$xml = new Xml($source);
$expects = '<a:container xmlns:a="http://example.com/a" xmlns:b="http://example.com/b" xmlns:c="http://example.com/c" xmlns:d="http://example.com/d" xmlns:e="http://example.com/e" xmlns:f="http://example.com/f"><b:rule test=""><c:result>value</c:result></b:rule><d:rule test=""><e:result>value</e:result></d:rule></a:container>';
$_xml =& XmlManager::getInstance();
$xml->addNamespace('f', 'http://example.com/f');
$result = $xml->toString(array('cdata' => false));
$this->assertEqual($expects, $result);
} | testNamespaces method
@access public
@return void | testNamespaces | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testEscapeCharSerialization() {
$xml = new Xml(array('text' => 'JavaScript & DHTML'), array('attributes' => false, 'format' => 'attributes'));
$result = $xml->toString(false);
$expected = '<std_class text="JavaScript & DHTML" />';
$this->assertEqual($expected, $result);
} | testEscapeCharSerialization method
@access public
@return void | testEscapeCharSerialization | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testCompleteEscapeCharSerialization() {
$xml = new Xml(array('text' => '<>&"\''), array('attributes' => false, 'format' => 'attributes'));
$result = $xml->toString(false);
$expected = '<std_class text="<>&"'" />';
$this->assertEqual($expected, $result);
} | testCompleteEscapeCharSerialization method
@access public
@return void | testCompleteEscapeCharSerialization | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testToArray() {
App::import('Set');
$string = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<rss version="2.0">
<channel>
<title>Cake PHP Google Group</title>
<link>http://groups.google.com/group/cake-php</link>
<description>Search this group before posting anything. There are over 20,000 posts and it&#39;s very likely your question was answered before. Visit the IRC channel #cakephp at irc.freenode.net for live chat with users and developers of Cake. If you post, tell us the version of Cake, PHP, and database.</description>
<language>en</language>
<item>
<title>constructng result array when using findall</title>
<link>http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f</link>
<description>i'm using cakephp to construct a logical data model array that will be <br> passed to a flex app. I have the following model association: <br> ServiceDay-&gt;(hasMany)ServiceTi me-&gt;(hasMany)ServiceTimePrice. So what <br> the current output from my findall is something like this example: <br> <p>Array( <br> [0] =&gt; Array(</description>
<guid isPermaLink="true">http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f</guid>
<author>[email protected](bpscrugs)</author>
<pubDate>Fri, 28 Dec 2007 00:44:14 UT</pubDate>
</item>
<item>
<title>Re: share views between actions?</title>
<link>http://groups.google.com/group/cake-php/msg/8b350d898707dad8</link>
<description>Then perhaps you might do us all a favour and refrain from replying to <br> things you do not understand. That goes especially for asinine comments. <br> Indeed. <br> To sum up: <br> No comment. <br> In my day, a simple &quot;RTFM&quot; would suffice. I'll keep in mind to ignore any <br> further responses from you. <br> You (and I) were referring to the *online documentation*, not other</description>
<guid isPermaLink="true">http://groups.google.com/group/cake-php/msg/8b350d898707dad8</guid>
<author>[email protected](subtropolis zijn)</author>
<pubDate>Fri, 28 Dec 2007 00:45:01 UT</pubDate>
</item>
</channel>
</rss>';
$xml = new Xml($string);
$result = $xml->toArray();
$expected = array('Rss' => array(
'version' => '2.0',
'Channel' => array(
'title' => 'Cake PHP Google Group',
'link' => 'http://groups.google.com/group/cake-php',
'description' => 'Search this group before posting anything. There are over 20,000 posts and it's very likely your question was answered before. Visit the IRC channel #cakephp at irc.freenode.net for live chat with users and developers of Cake. If you post, tell us the version of Cake, PHP, and database.',
'language' => 'en',
'Item' => array(
array(
'title' => 'constructng result array when using findall',
'link' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f',
'description' => "i'm using cakephp to construct a logical data model array that will be <br> passed to a flex app. I have the following model association: <br> ServiceDay->(hasMany)ServiceTi me->(hasMany)ServiceTimePrice. So what <br> the current output from my findall is something like this example: <br><p>Array( <br> [0] => Array(",
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f'),
'author' => '[email protected](bpscrugs)',
'pubDate' => 'Fri, 28 Dec 2007 00:44:14 UT',
),
array(
'title' => 'Re: share views between actions?',
'link' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8',
'description' => 'Then perhaps you might do us all a favour and refrain from replying to <br> things you do not understand. That goes especially for asinine comments. <br> Indeed. <br> To sum up: <br> No comment. <br> In my day, a simple "RTFM" would suffice. I\'ll keep in mind to ignore any <br> further responses from you. <br> You (and I) were referring to the *online documentation*, not other',
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8'),
'author' => '[email protected](subtropolis zijn)',
'pubDate' => 'Fri, 28 Dec 2007 00:45:01 UT'
)
)
)
));
$this->assertEqual($result, $expected);
$string ='<data><post title="Title of this post" description="cool"/></data>';
$xml = new Xml($string);
$result = $xml->toArray();
$expected = array('Data' => array('Post' => array('title' => 'Title of this post', 'description' => 'cool')));
$this->assertEqual($result, $expected);
$xml = new Xml('<example><item><title>An example of a correctly reversed XMLNode</title><desc/></item></example>');
$result = Set::reverse($xml);
$expected = array(
'Example' => array(
'Item' => array(
'title' => 'An example of a correctly reversed XMLNode',
'desc' => array(),
)
)
);
$this->assertIdentical($result, $expected);
$xml = new Xml('<example><item attr="123"><titles><title>title1</title><title>title2</title></titles></item></example>');
$result = $xml->toArray();
$expected = array(
'Example' => array(
'Item' => array(
'attr' => '123',
'Titles' => array(
'Title' => array('title1', 'title2')
)
)
)
);
$this->assertIdentical($result, $expected);
$xml = new Xml('<example attr="ex_attr"><item attr="123"><titles>list</titles>textforitems</item></example>');
$result = $xml->toArray();
$expected = array(
'Example' => array(
'attr' => 'ex_attr',
'Item' => array(
'attr' => '123',
'titles' => 'list',
'value' => 'textforitems'
)
)
);
$this->assertIdentical($result, $expected);
$xml = new Xml('<example attr="ex_attr"><item attr="123"><titles>list</titles>textforitems</item></example>');
$example = $xml->child('example');
$item = $example->child('item');
$result = $item->toArray();
$expected = array(
'attr' => '123',
'titles' => 'list',
'value' => 'textforitems'
);
$this->assertIdentical($result, $expected);
$string = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<rss version="2.0">
<channel>
<title>Cake PHP Google Group</title>
<link>http://groups.google.com/group/cake-php</link>
<description>Search this group before posting anything. There are over 20,000 posts and it&#39;s very likely your question was answered before. Visit the IRC channel #cakephp at irc.freenode.net for live chat with users and developers of Cake. If you post, tell us the version of Cake, PHP, and database.</description>
<language>en</language>
<item>
<title>constructng result array when using findall</title>
<link>http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f</link>
<description>i'm using cakephp to construct a logical data model array that will be <br> passed to a flex app. I have the following model association: <br> ServiceDay-&gt;(hasMany)ServiceTi me-&gt;(hasMany)ServiceTimePrice. So what <br> the current output from my findall is something like this example: <br> <p>Array( <br> [0] =&gt; Array(</description>
<dc:creator>cakephp</dc:creator>
<category><![CDATA[cakephp]]></category>
<category><![CDATA[model]]></category>
<guid isPermaLink="true">http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f</guid>
<author>[email protected](bpscrugs)</author>
<pubDate>Fri, 28 Dec 2007 00:44:14 UT</pubDate>
</item>
<item>
<title>Re: share views between actions?</title>
<link>http://groups.google.com/group/cake-php/msg/8b350d898707dad8</link>
<description>Then perhaps you might do us all a favour and refrain from replying to <br> things you do not understand. That goes especially for asinine comments. <br> Indeed. <br> To sum up: <br> No comment. <br> In my day, a simple &quot;RTFM&quot; would suffice. I'll keep in mind to ignore any <br> further responses from you. <br> You (and I) were referring to the *online documentation*, not other</description>
<dc:creator>cakephp</dc:creator>
<category><![CDATA[cakephp]]></category>
<category><![CDATA[model]]></category>
<guid isPermaLink="true">http://groups.google.com/group/cake-php/msg/8b350d898707dad8</guid>
<author>[email protected](subtropolis zijn)</author>
<pubDate>Fri, 28 Dec 2007 00:45:01 UT</pubDate>
</item>
</channel>
</rss>';
$xml = new Xml($string);
$result = $xml->toArray();
$expected = array('Rss' => array(
'version' => '2.0',
'Channel' => array(
'title' => 'Cake PHP Google Group',
'link' => 'http://groups.google.com/group/cake-php',
'description' => 'Search this group before posting anything. There are over 20,000 posts and it's very likely your question was answered before. Visit the IRC channel #cakephp at irc.freenode.net for live chat with users and developers of Cake. If you post, tell us the version of Cake, PHP, and database.',
'language' => 'en',
'Item' => array(
array(
'title' => 'constructng result array when using findall',
'link' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f',
'description' => "i'm using cakephp to construct a logical data model array that will be <br> passed to a flex app. I have the following model association: <br> ServiceDay->(hasMany)ServiceTi me->(hasMany)ServiceTimePrice. So what <br> the current output from my findall is something like this example: <br><p>Array( <br> [0] => Array(",
'creator' => 'cakephp',
'Category' => array('cakephp', 'model'),
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f'),
'author' => '[email protected](bpscrugs)',
'pubDate' => 'Fri, 28 Dec 2007 00:44:14 UT',
),
array(
'title' => 'Re: share views between actions?',
'link' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8',
'description' => 'Then perhaps you might do us all a favour and refrain from replying to <br> things you do not understand. That goes especially for asinine comments. <br> Indeed. <br> To sum up: <br> No comment. <br> In my day, a simple "RTFM" would suffice. I\'ll keep in mind to ignore any <br> further responses from you. <br> You (and I) were referring to the *online documentation*, not other',
'creator' => 'cakephp',
'Category' => array('cakephp', 'model'),
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8'),
'author' => '[email protected](subtropolis zijn)',
'pubDate' => 'Fri, 28 Dec 2007 00:45:01 UT'
)
)
)
));
$this->assertEqual($result, $expected);
$text = "<?xml version='1.0' encoding='utf-8'?>
<course>
<comps>
<comp>1</comp>
<comp>2</comp>
<comp>3</comp>
<comp>4</comp>
</comps>
</course>";
$xml = new Xml($text);
$result = $xml->toArray();
$expected = array('Course' => array(
'Comps' => array(
'Comp' => array(
1, 2, 3, 4
)
)
));
$this->assertEqual($result, $expected);
$text = '<?xml version="1.0" encoding="UTF-8"?>
<XRDS xmlns="xri://$xrds">
<XRD xml:id="oauth" xmlns="xri://$XRD*($v*2.0)" version="2.0">
<Type>xri://$xrds*simple</Type>
<Expires>2008-04-13T07:34:58Z</Expires>
<Service>
<Type>http://oauth.net/core/1.0/endpoint/authorize</Type>
<Type>http://oauth.net/core/1.0/parameters/auth-header</Type>
<Type>http://oauth.net/core/1.0/parameters/uri-query</Type>
<URI priority="10">https://ma.gnolia.com/oauth/authorize</URI>
<URI priority="20">http://ma.gnolia.com/oauth/authorize</URI>
</Service>
</XRD>
<XRD xmlns="xri://$XRD*($v*2.0)" version="2.0">
<Type>xri://$xrds*simple</Type>
<Service priority="10">
<Type>http://oauth.net/discovery/1.0</Type>
<URI>#oauth</URI>
</Service>
</XRD>
</XRDS>';
$xml = new Xml($text);
$result = $xml->toArray();
$expected = array('XRDS' => array(
'xmlns' => 'xri://$xrds',
'XRD' => array(
array(
'xml:id' => 'oauth',
'xmlns' => 'xri://$XRD*($v*2.0)',
'version' => '2.0',
'Type' => 'xri://$xrds*simple',
'Expires' => '2008-04-13T07:34:58Z',
'Service' => array(
'Type' => array(
'http://oauth.net/core/1.0/endpoint/authorize',
'http://oauth.net/core/1.0/parameters/auth-header',
'http://oauth.net/core/1.0/parameters/uri-query'
),
'URI' => array(
array(
'value' => 'https://ma.gnolia.com/oauth/authorize',
'priority' => '10',
),
array(
'value' => 'http://ma.gnolia.com/oauth/authorize',
'priority' => '20'
)
)
)
),
array(
'xmlns' => 'xri://$XRD*($v*2.0)',
'version' => '2.0',
'Type' => 'xri://$xrds*simple',
'Service' => array(
'priority' => '10',
'Type' => 'http://oauth.net/discovery/1.0',
'URI' => '#oauth'
)
)
)
));
$this->assertEqual($result, $expected);
$text = '<?xml version="1.0" encoding="UTF-8"?>
<root>
<child id="1" other="1" />
<child id="2" other="1" />
<child id="3" other="1" />
<child id="4" other="1" />
<child id="5" other="1" />
</root>';
$xml = new Xml($text);
$result = $xml->toArray();
$expected = array(
'Root' => array(
'Child' => array(
array('id' => 1, 'other' => 1),
array('id' => 2, 'other' => 1),
array('id' => 3, 'other' => 1),
array('id' => 4, 'other' => 1),
array('id' => 5, 'other' => 1)
)
)
);
$this->assertEqual($result, $expected);
$text = '<main><first label="first type node 1" /><first label="first type node 2" /><second label="second type node" /></main>';
$xml = new Xml($text);
$result = $xml->toArray();
$expected = array(
'Main' => array(
'First' => array(
array('label' => 'first type node 1'),
array('label' => 'first type node 2')
),
'Second' => array('label'=>'second type node')
)
);
$this->assertIdentical($result,$expected);
$text = '<main><first label="first type node 1" /><first label="first type node 2" /><second label="second type node" /><collection><fifth label="fifth type node"/><third label="third type node 1"/><third label="third type node 2"/><third label="third type node 3"/><fourth label="fourth type node"/></collection></main>';
$xml = new Xml($text);
$result = $xml->toArray();
$expected = array(
'Main' => array(
'First' => array(
array('label' => 'first type node 1'),
array('label' => 'first type node 2')
),
'Second' => array('label'=>'second type node'),
'Collection' => array(
'Fifth' => array('label' => 'fifth type node'),
'Third' => array(
array('label' => 'third type node 1'),
array('label' => 'third type node 2'),
array('label' => 'third type node 3'),
),
'Fourth' => array('label' => 'fourth type node'),
)
)
);
$this->assertIdentical($result,$expected);
} | testToArray method
@access public
@return void | testToArray | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testAppend() {
$parentNode = new XmlNode('ourParentNode');
$parentNode->append( new XmlNode('ourChildNode'));
$first =& $parentNode->first();
$this->assertEqual($first->name, 'ourChildNode');
$string = 'ourChildNode';
$parentNode = new XmlNode('ourParentNode');
$parentNode->append($string);
$last =& $parentNode->last();
$this->assertEqual($last->name, 'ourChildNode');
$this->expectError();
$parentNode->append($parentNode);
} | testAppend method
@access public
@return void | testAppend | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testNamespacing() {
$node = new Xml('<xml></xml>');
$node->addNamespace('cake', 'http://cakephp.org');
$this->assertEqual($node->toString(), '<xml xmlns:cake="http://cakephp.org" />');
$this->assertTrue($node->removeNamespace('cake'));
$this->assertEqual($node->toString(), '<xml />');
$node = new Xml('<xml xmlns:cake="http://cakephp.org" />');
$this->assertTrue($node->removeNamespace('cake'));
$this->assertEqual($node->toString(), '<xml />');
$node->addNamespace('cake', 'http://cakephp.org');
$this->assertEqual($node->toString(), '<xml xmlns:cake="http://cakephp.org" />');
} | testNamespacing method
@access public
@return void | testNamespacing | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testCamelize() {
$xmlString = '<methodCall><methodName>examples.getStateName</methodName>' .
'<params><param><value><i4>41</i4></value></param></params></methodCall>';
$Xml = new Xml($xmlString);
$expected = array(
'methodCall' => array(
'methodName' => 'examples.getStateName',
'params' => array(
'param' => array('value' => array('i4' => 41)))));
$this->assertEqual($expected, $Xml->toArray(false));
$Xml = new Xml($xmlString);
$expected = array(
'MethodCall' => array(
'methodName' => 'examples.getStateName',
'Params' => array(
'Param' => array('Value' => array('i4' => 41)))));
$this->assertEqual($expected, $Xml->toArray());
} | testCamelize method
@access public
@return void | testCamelize | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testNumericDataHandling() {
$data = '<xml><data>012345</data></xml>';
$node = new Xml();
$node->load($data);
$node->parse();
$result = $node->first();
$result = $result->children("data");
$result = $result[0]->first();
$this->assertEqual($result->value, '012345');
} | testNumericDataHandling method
@access public
@return void | testNumericDataHandling | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testMemoryLeakInConstructor() {
if ($this->skipIf(!function_exists('memory_get_usage'), 'Cannot test memory leaks without memory_get_usage')) {
return;
}
$data = '<?xml version="1.0" encoding="UTF-8"?><content>TEST</content>';
$start = memory_get_usage();
for ($i = 0; $i <= 300; $i++) {
$test =& new XML($data);
$test->__destruct();
unset($test);
}
$end = memory_get_usage();
$this->assertWithinMargin($start, $end, 3600, 'Memory leaked %s');
} | test that creating an xml object does not leak memory
@return void | testMemoryLeakInConstructor | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function testToArrayAlternate() {
$sXml =
'<t1>
<t2>A</t2>
<t2><t3>AAA</t3>B</t2>
<t2>C</t2>
</t1>';
$xml = new Xml($sXml);
$result = $xml->toArray();
$expected = array(
'T1' => array(
'T2' => array(
'A',
array('t3' => 'AAA', 'value' => 'B'),
'C'
)
)
);
$this->assertIdentical($result, $expected);
$result = $xml->toArray(false);
$expected = array(
't1' => array(
't2' => array(
'A',
array('t3' => 'AAA', 'value' => 'B'),
'C'
)
)
);
$this->assertIdentical($result, $expected);
$sXml =
'<t1>
<t2>A</t2>
<t2>B</t2>
<t2>
<t3>CCC</t3>
</t2>
</t1>';
$xml = new Xml($sXml);
$result = $xml->toArray();
$expected = array(
'T1' => array(
'T2' => array(
'A',
'B',
array('t3' => 'CCC'),
)
)
);
$this->assertIdentical($result, $expected);
$result = $xml->toArray(false);
$expected = array(
't1' => array(
't2' => array(
'A',
'B',
array('t3' => 'CCC'),
)
)
);
$this->assertIdentical($result, $expected);
$sXml =
'<t1>
<t2>A</t2>
<t2></t2>
<t2>C</t2>
</t1>';
$xml = new Xml($sXml);
$result = $xml->toArray();
$expected = array(
'T1' => array(
'T2' => array(
'A',
array(),
'C'
)
)
);
$this->assertIdentical($result, $expected);
$result = $xml->toArray(false);
$expected = array(
't1' => array(
't2' => array(
'A',
array(),
'C'
)
)
);
$this->assertIdentical($result, $expected);
$sXml =
'<stuff>
<foo name="abc-16" profile-id="Default" />
<foo name="abc-17" profile-id="Default" >
<bar id="HelloWorld" />
</foo>
<foo name="abc-asdf" profile-id="Default" />
<foo name="cba-1A" profile-id="Default">
<bar id="Baz" />
</foo>
<foo name="cba-2A" profile-id="Default">
<bar id="Baz" />
</foo>
<foo name="qa" profile-id="Default" />
</stuff>';
$xml = new Xml($sXml);
$result = $xml->toArray();
$expected = array(
'Stuff' => array(
'Foo' => array(
array('name' => 'abc-16', 'profile-id' => 'Default'),
array('name' => 'abc-17', 'profile-id' => 'Default',
'Bar' => array('id' => 'HelloWorld')),
array('name' => 'abc-asdf', 'profile-id' => 'Default'),
array('name' => 'cba-1A', 'profile-id' => 'Default',
'Bar' => array('id' => 'Baz')),
array('name' => 'cba-2A', 'profile-id' => 'Default',
'Bar' => array('id' => 'Baz')),
array('name' => 'qa', 'profile-id' => 'Default'),
)
)
);
$this->assertIdentical($result, $expected);
$result = $xml->toArray(false);
$expected = array(
'stuff' => array(
'foo' => array(
array('name' => 'abc-16', 'profile-id' => 'Default'),
array('name' => 'abc-17', 'profile-id' => 'Default',
'bar' => array('id' => 'HelloWorld')),
array('name' => 'abc-asdf', 'profile-id' => 'Default'),
array('name' => 'cba-1A', 'profile-id' => 'Default',
'bar' => array('id' => 'Baz')),
array('name' => 'cba-2A', 'profile-id' => 'Default',
'bar' => array('id' => 'Baz')),
array('name' => 'qa', 'profile-id' => 'Default'),
)
)
);
$this->assertIdentical($result, $expected);
$sXml =
'<root>
<node name="first" />
<node name="second"><subnode name="first sub" /><subnode name="second sub" /></node>
<node name="third" />
</root>';
$xml = new Xml($sXml);
$result = $xml->toArray();
$expected = array(
'Root' => array(
'Node' => array(
array('name' => 'first'),
array('name' => 'second',
'Subnode' => array(
array('name' => 'first sub'),
array('name' => 'second sub'))),
array('name' => 'third'),
)
)
);
$this->assertIdentical($result, $expected);
$result = $xml->toArray(false);
$expected = array(
'root' => array(
'node' => array(
array('name' => 'first'),
array('name' => 'second',
'subnode' => array(
array('name' => 'first sub'),
array('name' => 'second sub'))),
array('name' => 'third'),
)
)
);
$this->assertIdentical($result, $expected);
} | Test toArray with alternate inputs.
@return void | testToArrayAlternate | php | Datawalke/Coordino | cake/tests/cases/libs/xml.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/xml.test.php | MIT |
function skip() {
$skip = true;
if (function_exists('apc_store')) {
$skip = false;
}
$this->skipIf($skip, '%s Apc is not installed or configured properly');
} | skip method
@access public
@return void | skip | php | Datawalke/Coordino | cake/tests/cases/libs/cache/apc.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/apc.test.php | MIT |
function setUp() {
$this->_cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', false);
Cache::config('apc', array('engine' => 'Apc', 'prefix' => 'cake_'));
} | setUp method
@access public
@return void | setUp | php | Datawalke/Coordino | cake/tests/cases/libs/cache/apc.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/apc.test.php | MIT |
function tearDown() {
Configure::write('Cache.disable', $this->_cacheDisable);
Cache::drop('apc');
Cache::config('default');
} | tearDown method
@access public
@return void | tearDown | php | Datawalke/Coordino | cake/tests/cases/libs/cache/apc.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/apc.test.php | MIT |
function testReadAndWriteCache() {
Cache::set(array('duration' => 1));
$result = Cache::read('test');
$expecting = '';
$this->assertEqual($result, $expecting);
$data = 'this is a test of the emergency broadcasting system';
$result = Cache::write('test', $data);
$this->assertTrue($result);
$result = Cache::read('test');
$expecting = $data;
$this->assertEqual($result, $expecting);
Cache::delete('test');
} | testReadAndWriteCache method
@access public
@return void | testReadAndWriteCache | php | Datawalke/Coordino | cake/tests/cases/libs/cache/apc.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/apc.test.php | MIT |
function testReadWriteDurationZero() {
Cache::config('apc', array('engine' => 'Apc', 'duration' => 0, 'prefix' => 'cake_'));
Cache::write('zero', 'Should save', 'apc');
sleep(1);
$result = Cache::read('zero', 'apc');
$this->assertEqual('Should save', $result);
} | Writing cache entries with duration = 0 (forever) should work.
@return void | testReadWriteDurationZero | php | Datawalke/Coordino | cake/tests/cases/libs/cache/apc.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/apc.test.php | MIT |
function testExpiry() {
Cache::set(array('duration' => 1));
$result = Cache::read('test');
$this->assertFalse($result);
$data = 'this is a test of the emergency broadcasting system';
$result = Cache::write('other_test', $data);
$this->assertTrue($result);
sleep(2);
$result = Cache::read('other_test');
$this->assertFalse($result);
Cache::set(array('duration' => 1));
$data = 'this is a test of the emergency broadcasting system';
$result = Cache::write('other_test', $data);
$this->assertTrue($result);
sleep(2);
$result = Cache::read('other_test');
$this->assertFalse($result);
sleep(2);
$result = Cache::read('other_test');
$this->assertFalse($result);
} | testExpiry method
@access public
@return void | testExpiry | php | Datawalke/Coordino | cake/tests/cases/libs/cache/apc.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/apc.test.php | MIT |
function testDeleteCache() {
$data = 'this is a test of the emergency broadcasting system';
$result = Cache::write('delete_test', $data);
$this->assertTrue($result);
$result = Cache::delete('delete_test');
$this->assertTrue($result);
} | testDeleteCache method
@access public
@return void | testDeleteCache | php | Datawalke/Coordino | cake/tests/cases/libs/cache/apc.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/apc.test.php | MIT |
function testDecrement() {
if ($this->skipIf(!function_exists('apc_dec'), 'No apc_dec() function, cannot test decrement() %s')) {
return;
}
$result = Cache::write('test_decrement', 5);
$this->assertTrue($result);
$result = Cache::decrement('test_decrement');
$this->assertEqual(4, $result);
$result = Cache::read('test_decrement');
$this->assertEqual(4, $result);
$result = Cache::decrement('test_decrement', 2);
$this->assertEqual(2, $result);
$result = Cache::read('test_decrement');
$this->assertEqual(2, $result);
} | testDecrement method
@access public
@return void | testDecrement | php | Datawalke/Coordino | cake/tests/cases/libs/cache/apc.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/apc.test.php | MIT |
function testIncrement() {
if ($this->skipIf(!function_exists('apc_inc'), 'No apc_inc() function, cannot test increment() %s')) {
return;
}
$result = Cache::write('test_increment', 5);
$this->assertTrue($result);
$result = Cache::increment('test_increment');
$this->assertEqual(6, $result);
$result = Cache::read('test_increment');
$this->assertEqual(6, $result);
$result = Cache::increment('test_increment', 2);
$this->assertEqual(8, $result);
$result = Cache::read('test_increment');
$this->assertEqual(8, $result);
} | testIncrement method
@access public
@return void | testIncrement | php | Datawalke/Coordino | cake/tests/cases/libs/cache/apc.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/apc.test.php | MIT |
function startCase() {
$this->_cacheDisable = Configure::read('Cache.disable');
$this->_cacheConfig = Cache::config('default');
Configure::write('Cache.disable', false);
Cache::config('default', array('engine' => 'File', 'path' => CACHE));
} | startCase method
@access public
@return void | startCase | php | Datawalke/Coordino | cake/tests/cases/libs/cache/file.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/file.test.php | MIT |
function endCase() {
Configure::write('Cache.disable', $this->_cacheDisable);
Cache::config('default', $this->_cacheConfig['settings']);
} | endCase method
@access public
@return void | endCase | php | Datawalke/Coordino | cake/tests/cases/libs/cache/file.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/file.test.php | MIT |
function testCacheDirChange() {
$result = Cache::config('sessions', array('engine'=> 'File', 'path' => TMP . 'sessions'));
$this->assertEqual($result['settings'], Cache::settings('sessions'));
$result = Cache::config('sessions', array('engine'=> 'File', 'path' => TMP . 'tests'));
$this->assertEqual($result['settings'], Cache::settings('sessions'));
$this->assertNotEqual($result['settings'], Cache::settings('default'));
} | testCacheDirChange method
@access public
@return void | testCacheDirChange | php | Datawalke/Coordino | cake/tests/cases/libs/cache/file.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/file.test.php | MIT |
function testReadAndWriteCache() {
Cache::config('default');
$result = Cache::write(null, 'here');
$this->assertFalse($result);
Cache::set(array('duration' => 1));
$result = Cache::read('test');
$expecting = '';
$this->assertEqual($result, $expecting);
$data = 'this is a test of the emergency broadcasting system';
$result = Cache::write('test', $data);
$this->assertTrue(file_exists(CACHE . 'cake_test'));
$result = Cache::read('test');
$expecting = $data;
$this->assertEqual($result, $expecting);
Cache::delete('test');
} | testReadAndWriteCache method
@access public
@return void | testReadAndWriteCache | php | Datawalke/Coordino | cake/tests/cases/libs/cache/file.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/file.test.php | MIT |
function testExpiry() {
Cache::set(array('duration' => 1));
$result = Cache::read('test');
$this->assertFalse($result);
$data = 'this is a test of the emergency broadcasting system';
$result = Cache::write('other_test', $data);
$this->assertTrue($result);
sleep(2);
$result = Cache::read('other_test');
$this->assertFalse($result);
Cache::set(array('duration' => "+1 second"));
$data = 'this is a test of the emergency broadcasting system';
$result = Cache::write('other_test', $data);
$this->assertTrue($result);
sleep(2);
$result = Cache::read('other_test');
$this->assertFalse($result);
} | testExpiry method
@access public
@return void | testExpiry | php | Datawalke/Coordino | cake/tests/cases/libs/cache/file.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/file.test.php | MIT |
function testDeleteCache() {
$data = 'this is a test of the emergency broadcasting system';
$result = Cache::write('delete_test', $data);
$this->assertTrue($result);
$result = Cache::delete('delete_test');
$this->assertTrue($result);
$this->assertFalse(file_exists(TMP . 'tests' . DS . 'delete_test'));
$result = Cache::delete('delete_test');
$this->assertFalse($result);
} | testDeleteCache method
@access public
@return void | testDeleteCache | php | Datawalke/Coordino | cake/tests/cases/libs/cache/file.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/file.test.php | MIT |
function testSerialize() {
Cache::config('default', array('engine' => 'File', 'serialize' => true));
$data = 'this is a test of the emergency broadcasting system';
$write = Cache::write('serialize_test', $data);
$this->assertTrue($write);
Cache::config('default', array('serialize' => false));
$read = Cache::read('serialize_test');
$newread = Cache::read('serialize_test');
$delete = Cache::delete('serialize_test');
$this->assertIdentical($read, serialize($data));
$this->assertIdentical(unserialize($newread), $data);
} | testSerialize method
@access public
@return void | testSerialize | php | Datawalke/Coordino | cake/tests/cases/libs/cache/file.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/file.test.php | MIT |
function testClear() {
Cache::config('default', array('engine' => 'File', 'duration' => 1));
$data = 'this is a test of the emergency broadcasting system';
$write = Cache::write('serialize_test1', $data);
$write = Cache::write('serialize_test2', $data);
$write = Cache::write('serialize_test3', $data);
$this->assertTrue(file_exists(CACHE . 'cake_serialize_test1'));
$this->assertTrue(file_exists(CACHE . 'cake_serialize_test2'));
$this->assertTrue(file_exists(CACHE . 'cake_serialize_test3'));
sleep(2);
$result = Cache::clear(true);
$this->assertTrue($result);
$this->assertFalse(file_exists(CACHE . 'cake_serialize_test1'));
$this->assertFalse(file_exists(CACHE . 'cake_serialize_test2'));
$this->assertFalse(file_exists(CACHE . 'cake_serialize_test3'));
$data = 'this is a test of the emergency broadcasting system';
$write = Cache::write('serialize_test1', $data);
$write = Cache::write('serialize_test2', $data);
$write = Cache::write('serialize_test3', $data);
$this->assertTrue(file_exists(CACHE . 'cake_serialize_test1'));
$this->assertTrue(file_exists(CACHE . 'cake_serialize_test2'));
$this->assertTrue(file_exists(CACHE . 'cake_serialize_test3'));
$result = Cache::clear();
$this->assertTrue($result);
$this->assertFalse(file_exists(CACHE . 'cake_serialize_test1'));
$this->assertFalse(file_exists(CACHE . 'cake_serialize_test2'));
$this->assertFalse(file_exists(CACHE . 'cake_serialize_test3'));
Cache::config('default', array('engine' => 'File', 'path' => CACHE . 'views'));
$data = 'this is a test of the emergency broadcasting system';
$write = Cache::write('controller_view_1', $data);
$write = Cache::write('controller_view_2', $data);
$write = Cache::write('controller_view_3', $data);
$write = Cache::write('controller_view_10', $data);
$write = Cache::write('controller_view_11', $data);
$write = Cache::write('controller_view_12', $data);
$this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_1'));
$this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_2'));
$this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_3'));
$this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_10'));
$this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_11'));
$this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_12'));
clearCache('controller_view_1', 'views', '');
$this->assertFalse(file_exists(CACHE . 'views'. DS . 'cake_controller_view_1'));
$this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_2'));
$this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_3'));
$this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_10'));
$this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_11'));
$this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_12'));
clearCache('controller_view', 'views', '');
$this->assertFalse(file_exists(CACHE . 'views'. DS . 'cake_controller_view_1'));
$this->assertFalse(file_exists(CACHE . 'views'. DS . 'cake_controller_view_2'));
$this->assertFalse(file_exists(CACHE . 'views'. DS . 'cake_controller_view_3'));
$this->assertFalse(file_exists(CACHE . 'views'. DS . 'cake_controller_view_10'));
$this->assertFalse(file_exists(CACHE . 'views'. DS . 'cake_controller_view_11'));
$this->assertFalse(file_exists(CACHE . 'views'. DS . 'cake_controller_view_12'));
$write = Cache::write('controller_view_1', $data);
$write = Cache::write('controller_view_2', $data);
$write = Cache::write('controller_view_3', $data);
$write = Cache::write('controller_view_10', $data);
$write = Cache::write('controller_view_11', $data);
$write = Cache::write('controller_view_12', $data);
$this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_1'));
$this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_2'));
$this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_3'));
$this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_10'));
$this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_11'));
$this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_12'));
clearCache(array('controller_view_2', 'controller_view_11', 'controller_view_12'), 'views', '');
$this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_1'));
$this->assertFalse(file_exists(CACHE . 'views'. DS . 'cake_controller_view_2'));
$this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_3'));
$this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_10'));
$this->assertFalse(file_exists(CACHE . 'views'. DS . 'cake_controller_view_11'));
$this->assertFalse(file_exists(CACHE . 'views'. DS . 'cake_controller_view_12'));
clearCache('controller_view');
Cache::config('default', array('engine' => 'File', 'path' => CACHE));
} | testClear method
@access public
@return void | testClear | php | Datawalke/Coordino | cake/tests/cases/libs/cache/file.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/file.test.php | MIT |
function testClearWithPrefixes() {
$FileOne =& new FileEngine();
$FileOne->init(array(
'prefix' => 'prefix_one_',
'duration' => DAY
));
$FileTwo =& new FileEngine();
$FileTwo->init(array(
'prefix' => 'prefix_two_',
'duration' => DAY
));
$data1 = $data2 = $expected = 'content to cache';
$FileOne->write('key_one', $data1, DAY);
$FileTwo->write('key_two', $data2, DAY);
$this->assertEqual($FileOne->read('key_one'), $expected);
$this->assertEqual($FileTwo->read('key_two'), $expected);
$FileOne->clear(false);
$this->assertEqual($FileTwo->read('key_two'), $expected, 'secondary config was cleared by accident.');
} | test that clear() doesn't wipe files not in the current engine's prefix.
@return void | testClearWithPrefixes | php | Datawalke/Coordino | cake/tests/cases/libs/cache/file.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/file.test.php | MIT |
function testKeyPath() {
$result = Cache::write('views.countries.something', 'here');
$this->assertTrue($result);
$this->assertTrue(file_exists(CACHE . 'cake_views_countries_something'));
$result = Cache::read('views.countries.something');
$this->assertEqual($result, 'here');
$result = Cache::clear();
$this->assertTrue($result);
} | testKeyPath method
@access public
@return void | testKeyPath | php | Datawalke/Coordino | cake/tests/cases/libs/cache/file.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/file.test.php | MIT |
function testRemoveWindowsSlashesFromCache() {
Cache::config('windows_test', array('engine' => 'File', 'isWindows' => true, 'prefix' => null, 'path' => TMP));
$expected = array (
'C:\dev\prj2\sites\cake\libs' => array(
0 => 'C:\dev\prj2\sites\cake\libs', 1 => 'C:\dev\prj2\sites\cake\libs\view',
2 => 'C:\dev\prj2\sites\cake\libs\view\scaffolds', 3 => 'C:\dev\prj2\sites\cake\libs\view\pages',
4 => 'C:\dev\prj2\sites\cake\libs\view\layouts', 5 => 'C:\dev\prj2\sites\cake\libs\view\layouts\xml',
6 => 'C:\dev\prj2\sites\cake\libs\view\layouts\rss', 7 => 'C:\dev\prj2\sites\cake\libs\view\layouts\js',
8 => 'C:\dev\prj2\sites\cake\libs\view\layouts\email', 9 => 'C:\dev\prj2\sites\cake\libs\view\layouts\email\text',
10 => 'C:\dev\prj2\sites\cake\libs\view\layouts\email\html', 11 => 'C:\dev\prj2\sites\cake\libs\view\helpers',
12 => 'C:\dev\prj2\sites\cake\libs\view\errors', 13 => 'C:\dev\prj2\sites\cake\libs\view\elements',
14 => 'C:\dev\prj2\sites\cake\libs\view\elements\email', 15 => 'C:\dev\prj2\sites\cake\libs\view\elements\email\text',
16 => 'C:\dev\prj2\sites\cake\libs\view\elements\email\html', 17 => 'C:\dev\prj2\sites\cake\libs\model',
18 => 'C:\dev\prj2\sites\cake\libs\model\datasources', 19 => 'C:\dev\prj2\sites\cake\libs\model\datasources\dbo',
20 => 'C:\dev\prj2\sites\cake\libs\model\behaviors', 21 => 'C:\dev\prj2\sites\cake\libs\controller',
22 => 'C:\dev\prj2\sites\cake\libs\controller\components', 23 => 'C:\dev\prj2\sites\cake\libs\cache'),
'C:\dev\prj2\sites\main_site\vendors' => array(
0 => 'C:\dev\prj2\sites\main_site\vendors', 1 => 'C:\dev\prj2\sites\main_site\vendors\shells',
2 => 'C:\dev\prj2\sites\main_site\vendors\shells\templates', 3 => 'C:\dev\prj2\sites\main_site\vendors\shells\templates\cdc_project',
4 => 'C:\dev\prj2\sites\main_site\vendors\shells\tasks', 5 => 'C:\dev\prj2\sites\main_site\vendors\js',
6 => 'C:\dev\prj2\sites\main_site\vendors\css'),
'C:\dev\prj2\sites\vendors' => array(
0 => 'C:\dev\prj2\sites\vendors', 1 => 'C:\dev\prj2\sites\vendors\simpletest',
2 => 'C:\dev\prj2\sites\vendors\simpletest\test', 3 => 'C:\dev\prj2\sites\vendors\simpletest\test\support',
4 => 'C:\dev\prj2\sites\vendors\simpletest\test\support\collector', 5 => 'C:\dev\prj2\sites\vendors\simpletest\extensions',
6 => 'C:\dev\prj2\sites\vendors\simpletest\extensions\testdox', 7 => 'C:\dev\prj2\sites\vendors\simpletest\docs',
8 => 'C:\dev\prj2\sites\vendors\simpletest\docs\fr', 9 => 'C:\dev\prj2\sites\vendors\simpletest\docs\en'),
'C:\dev\prj2\sites\main_site\views\helpers' => array(
0 => 'C:\dev\prj2\sites\main_site\views\helpers')
);
Cache::write('test_dir_map', $expected, 'windows_test');
$data = Cache::read('test_dir_map', 'windows_test');
Cache::delete('test_dir_map', 'windows_test');
$this->assertEqual($expected, $data);
Cache::drop('windows_test');
} | testRemoveWindowsSlashesFromCache method
@access public
@return void | testRemoveWindowsSlashesFromCache | php | Datawalke/Coordino | cake/tests/cases/libs/cache/file.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/file.test.php | MIT |
function testWriteQuotedString() {
Cache::config('default', array('engine' => 'File', 'path' => TMP . 'tests'));
Cache::write('App.doubleQuoteTest', '"this is a quoted string"');
$this->assertIdentical(Cache::read('App.doubleQuoteTest'), '"this is a quoted string"');
Cache::write('App.singleQuoteTest', "'this is a quoted string'");
$this->assertIdentical(Cache::read('App.singleQuoteTest'), "'this is a quoted string'");
Cache::config('default', array('isWindows' => true, 'path' => TMP . 'tests'));
$this->assertIdentical(Cache::read('App.doubleQuoteTest'), '"this is a quoted string"');
Cache::write('App.singleQuoteTest', "'this is a quoted string'");
$this->assertIdentical(Cache::read('App.singleQuoteTest'), "'this is a quoted string'");
} | testWriteQuotedString method
@access public
@return void | testWriteQuotedString | php | Datawalke/Coordino | cake/tests/cases/libs/cache/file.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/file.test.php | MIT |
function testErrorWhenPathDoesNotExist() {
if ($this->skipIf(is_dir(TMP . 'tests' . DS . 'file_failure'), 'Cannot run test directory exists. %s')) {
return;
}
$this->expectError();
Cache::config('failure', array(
'engine' => 'File',
'path' => TMP . 'tests' . DS . 'file_failure'
));
Cache::drop('failure');
} | check that FileEngine generates an error when a configured Path does not exist.
@return void | testErrorWhenPathDoesNotExist | php | Datawalke/Coordino | cake/tests/cases/libs/cache/file.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/file.test.php | MIT |
function parseServerString($server) {
return $this->_parseServerString($server);
} | public accessor to _parseServerString
@param string $server
@return array | parseServerString | php | Datawalke/Coordino | cake/tests/cases/libs/cache/memcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/memcache.test.php | MIT |
function skip() {
$skip = true;
if (class_exists('Memcache')) {
$skip = false;
}
$this->skipIf($skip, '%s Memcache is not installed or configured properly.');
} | skip method
@access public
@return void | skip | php | Datawalke/Coordino | cake/tests/cases/libs/cache/memcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/memcache.test.php | MIT |
function setUp() {
$this->_cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', false);
Cache::config('memcache', array(
'engine' => 'Memcache',
'prefix' => 'cake_',
'duration' => 3600
));
} | setUp method
@access public
@return void | setUp | php | Datawalke/Coordino | cake/tests/cases/libs/cache/memcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/memcache.test.php | MIT |
function tearDown() {
Configure::write('Cache.disable', $this->_cacheDisable);
Cache::drop('memcache');
Cache::config('default');
} | tearDown method
@access public
@return void | tearDown | php | Datawalke/Coordino | cake/tests/cases/libs/cache/memcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/memcache.test.php | MIT |
function testSettings() {
$settings = Cache::settings();
unset($settings['serialize'], $settings['path']);
$expecting = array(
'prefix' => 'cake_',
'duration'=> 3600,
'probability' => 100,
'servers' => array('127.0.0.1'),
'compress' => false,
'engine' => 'Memcache',
'persistent' => true,
);
$this->assertEqual($settings, $expecting);
} | testSettings method
@access public
@return void | testSettings | php | Datawalke/Coordino | cake/tests/cases/libs/cache/memcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/memcache.test.php | MIT |
function testMultipleServers() {
$servers = array('127.0.0.1:11211', '127.0.0.1:11222');
$available = true;
$Memcache =& new Memcache();
foreach($servers as $server) {
list($host, $port) = explode(':', $server);
if (!@$Memcache->connect($host, $port)) {
$available = false;
}
}
if ($this->skipIf(!$available, '%s Need memcache servers at ' . implode(', ', $servers) . ' to run this test')) {
return;
}
$Memcache =& new MemcacheEngine();
$Memcache->init(array('engine' => 'Memcache', 'servers' => $servers));
$servers = array_keys($Memcache->__Memcache->getExtendedStats());
$settings = $Memcache->settings();
$this->assertEqual($servers, $settings['servers']);
Cache::drop('dual_server');
} | testSettings method
@access public
@return void | testMultipleServers | php | Datawalke/Coordino | cake/tests/cases/libs/cache/memcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/memcache.test.php | MIT |
function testConnect() {
$Memcache =& new MemcacheEngine();
$Memcache->init(Cache::settings('memcache'));
$result = $Memcache->connect('127.0.0.1');
$this->assertTrue($result);
} | testConnect method
@access public
@return void | testConnect | php | Datawalke/Coordino | cake/tests/cases/libs/cache/memcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/memcache.test.php | MIT |
function testConnectIpv6() {
$Memcache =& new MemcacheEngine();
$result = $Memcache->init(array(
'prefix' => 'cake_',
'duration' => 200,
'engine' => 'Memcache',
'servers' => array(
'[::1]:11211'
)
));
$this->assertTrue($result);
} | test connecting to an ipv6 server.
@return void | testConnectIpv6 | php | Datawalke/Coordino | cake/tests/cases/libs/cache/memcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/memcache.test.php | MIT |
function testReadAndWriteCache() {
Cache::set(array('duration' => 1));
$result = Cache::read('test');
$expecting = '';
$this->assertEqual($result, $expecting);
$data = 'this is a test of the emergency broadcasting system';
$result = Cache::write('test', $data);
$this->assertTrue($result);
$result = Cache::read('test');
$expecting = $data;
$this->assertEqual($result, $expecting);
Cache::delete('test');
} | testReadAndWriteCache method
@access public
@return void | testReadAndWriteCache | php | Datawalke/Coordino | cake/tests/cases/libs/cache/memcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/memcache.test.php | MIT |
function testExpiry() {
Cache::set(array('duration' => 1));
$result = Cache::read('test');
$this->assertFalse($result);
$data = 'this is a test of the emergency broadcasting system';
$result = Cache::write('other_test', $data);
$this->assertTrue($result);
sleep(2);
$result = Cache::read('other_test');
$this->assertFalse($result);
Cache::set(array('duration' => "+1 second"));
$data = 'this is a test of the emergency broadcasting system';
$result = Cache::write('other_test', $data);
$this->assertTrue($result);
sleep(2);
$result = Cache::read('other_test');
$this->assertFalse($result);
Cache::config('memcache', array('duration' => '+1 second'));
sleep(2);
$result = Cache::read('other_test');
$this->assertFalse($result);
Cache::config('memcache', array('duration' => '+29 days'));
$data = 'this is a test of the emergency broadcasting system';
$result = Cache::write('long_expiry_test', $data);
$this->assertTrue($result);
sleep(2);
$result = Cache::read('long_expiry_test');
$expecting = $data;
$this->assertEqual($result, $expecting);
Cache::config('memcache', array('duration' => 3600));
} | testExpiry method
@access public
@return void | testExpiry | php | Datawalke/Coordino | cake/tests/cases/libs/cache/memcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/memcache.test.php | MIT |
function testDeleteCache() {
$data = 'this is a test of the emergency broadcasting system';
$result = Cache::write('delete_test', $data);
$this->assertTrue($result);
$result = Cache::delete('delete_test');
$this->assertTrue($result);
} | testDeleteCache method
@access public
@return void | testDeleteCache | php | Datawalke/Coordino | cake/tests/cases/libs/cache/memcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/memcache.test.php | MIT |
function testDecrement() {
$result = Cache::write('test_decrement', 5);
$this->assertTrue($result);
$result = Cache::decrement('test_decrement');
$this->assertEqual(4, $result);
$result = Cache::read('test_decrement');
$this->assertEqual(4, $result);
$result = Cache::decrement('test_decrement', 2);
$this->assertEqual(2, $result);
$result = Cache::read('test_decrement');
$this->assertEqual(2, $result);
} | testDecrement method
@access public
@return void | testDecrement | php | Datawalke/Coordino | cake/tests/cases/libs/cache/memcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/memcache.test.php | MIT |
function testIncrement() {
$result = Cache::write('test_increment', 5);
$this->assertTrue($result);
$result = Cache::increment('test_increment');
$this->assertEqual(6, $result);
$result = Cache::read('test_increment');
$this->assertEqual(6, $result);
$result = Cache::increment('test_increment', 2);
$this->assertEqual(8, $result);
$result = Cache::read('test_increment');
$this->assertEqual(8, $result);
} | testIncrement method
@access public
@return void | testIncrement | php | Datawalke/Coordino | cake/tests/cases/libs/cache/memcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/memcache.test.php | MIT |
function testConfigurationConflict() {
Cache::config('long_memcache', array(
'engine' => 'Memcache',
'duration'=> '+2 seconds',
'servers' => array('127.0.0.1:11211'),
));
Cache::config('short_memcache', array(
'engine' => 'Memcache',
'duration'=> '+1 seconds',
'servers' => array('127.0.0.1:11211'),
));
Cache::config('some_file', array('engine' => 'File'));
$this->assertTrue(Cache::write('duration_test', 'yay', 'long_memcache'));
$this->assertTrue(Cache::write('short_duration_test', 'boo', 'short_memcache'));
$this->assertEqual(Cache::read('duration_test', 'long_memcache'), 'yay', 'Value was not read %s');
$this->assertEqual(Cache::read('short_duration_test', 'short_memcache'), 'boo', 'Value was not read %s');
sleep(1);
$this->assertEqual(Cache::read('duration_test', 'long_memcache'), 'yay', 'Value was not read %s');
sleep(2);
$this->assertFalse(Cache::read('short_duration_test', 'short_memcache'), 'Cache was not invalidated %s');
$this->assertFalse(Cache::read('duration_test', 'long_memcache'), 'Value did not expire %s');
Cache::delete('duration_test', 'long_memcache');
Cache::delete('short_duration_test', 'short_memcache');
} | test that configurations don't conflict, when a file engine is declared after a memcache one.
@return void | testConfigurationConflict | php | Datawalke/Coordino | cake/tests/cases/libs/cache/memcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/memcache.test.php | MIT |
function testZeroDuration() {
Cache::config('memcache', array('duration' => 0));
$result = Cache::write('test_key', 'written!', 'memcache');
$this->assertTrue($result, 'Could not write with duration 0');
$result = Cache::read('test_key', 'memcache');
$this->assertEqual($result, 'written!');
} | test that a 0 duration can succesfully write.
@return void | testZeroDuration | php | Datawalke/Coordino | cake/tests/cases/libs/cache/memcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/memcache.test.php | MIT |
function testLongDurationEqualToZero() {
$memcache =& new TestMemcacheEngine();
$memcache->settings['compress'] = false;
$mock = new MemcacheMockMemcache();
$memcache->setMemcache($mock);
$mock->expectAt(0, 'set', array('key', 'value', false, 0));
$value = 'value';
$memcache->write('key', $value, 50 * DAY);
} | test that durations greater than 30 days never expire
@return void | testLongDurationEqualToZero | php | Datawalke/Coordino | cake/tests/cases/libs/cache/memcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/memcache.test.php | MIT |
function skip() {
$skip = true;
if (function_exists('xcache_set')) {
$skip = false;
}
$this->skipIf($skip, '%s Xcache is not installed or configured properly');
} | skip method
@access public
@return void | skip | php | Datawalke/Coordino | cake/tests/cases/libs/cache/xcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/xcache.test.php | MIT |
function setUp() {
$this->_cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', false);
Cache::config('xcache', array('engine' => 'Xcache', 'prefix' => 'cake_'));
} | setUp method
@access public
@return void | setUp | php | Datawalke/Coordino | cake/tests/cases/libs/cache/xcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/xcache.test.php | MIT |
function tearDown() {
Configure::write('Cache.disable', $this->_cacheDisable);
Cache::config('default');
} | tearDown method
@access public
@return void | tearDown | php | Datawalke/Coordino | cake/tests/cases/libs/cache/xcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/xcache.test.php | MIT |
function testSettings() {
$settings = Cache::settings();
$expecting = array(
'prefix' => 'cake_',
'duration'=> 3600,
'probability' => 100,
'engine' => 'Xcache',
);
$this->assertTrue(isset($settings['PHP_AUTH_USER']));
$this->assertTrue(isset($settings['PHP_AUTH_PW']));
unset($settings['PHP_AUTH_USER'], $settings['PHP_AUTH_PW']);
$this->assertEqual($settings, $expecting);
} | testSettings method
@access public
@return void | testSettings | php | Datawalke/Coordino | cake/tests/cases/libs/cache/xcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/xcache.test.php | MIT |
function testReadAndWriteCache() {
Cache::set(array('duration' => 1));
$result = Cache::read('test');
$expecting = '';
$this->assertEqual($result, $expecting);
$data = 'this is a test of the emergency broadcasting system';
$result = Cache::write('test', $data);
$this->assertTrue($result);
$result = Cache::read('test');
$expecting = $data;
$this->assertEqual($result, $expecting);
Cache::delete('test');
} | testReadAndWriteCache method
@access public
@return void | testReadAndWriteCache | php | Datawalke/Coordino | cake/tests/cases/libs/cache/xcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/xcache.test.php | MIT |
function testExpiry() {
Cache::set(array('duration' => 1));
$result = Cache::read('test');
$this->assertFalse($result);
$data = 'this is a test of the emergency broadcasting system';
$result = Cache::write('other_test', $data);
$this->assertTrue($result);
sleep(2);
$result = Cache::read('other_test');
$this->assertFalse($result);
Cache::set(array('duration' => "+1 second"));
$data = 'this is a test of the emergency broadcasting system';
$result = Cache::write('other_test', $data);
$this->assertTrue($result);
sleep(2);
$result = Cache::read('other_test');
$this->assertFalse($result);
} | testExpiry method
@access public
@return void | testExpiry | php | Datawalke/Coordino | cake/tests/cases/libs/cache/xcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/xcache.test.php | MIT |
function testDeleteCache() {
$data = 'this is a test of the emergency broadcasting system';
$result = Cache::write('delete_test', $data);
$this->assertTrue($result);
$result = Cache::delete('delete_test');
$this->assertTrue($result);
} | testDeleteCache method
@access public
@return void | testDeleteCache | php | Datawalke/Coordino | cake/tests/cases/libs/cache/xcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/xcache.test.php | MIT |
function testClearCache() {
$data = 'this is a test of the emergency broadcasting system';
$result = Cache::write('clear_test_1', $data);
$this->assertTrue($result);
$result = Cache::write('clear_test_2', $data);
$this->assertTrue($result);
$result = Cache::clear();
$this->assertTrue($result);
} | testClearCache method
@access public
@return void | testClearCache | php | Datawalke/Coordino | cake/tests/cases/libs/cache/xcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/xcache.test.php | MIT |
function testDecrement() {
$result = Cache::write('test_decrement', 5);
$this->assertTrue($result);
$result = Cache::decrement('test_decrement');
$this->assertEqual(4, $result);
$result = Cache::read('test_decrement');
$this->assertEqual(4, $result);
$result = Cache::decrement('test_decrement', 2);
$this->assertEqual(2, $result);
$result = Cache::read('test_decrement');
$this->assertEqual(2, $result);
} | testDecrement method
@access public
@return void | testDecrement | php | Datawalke/Coordino | cake/tests/cases/libs/cache/xcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/xcache.test.php | MIT |
function testIncrement() {
$result = Cache::write('test_increment', 5);
$this->assertTrue($result);
$result = Cache::increment('test_increment');
$this->assertEqual(6, $result);
$result = Cache::read('test_increment');
$this->assertEqual(6, $result);
$result = Cache::increment('test_increment', 2);
$this->assertEqual(8, $result);
$result = Cache::read('test_increment');
$this->assertEqual(8, $result);
} | testIncrement method
@access public
@return void | testIncrement | php | Datawalke/Coordino | cake/tests/cases/libs/cache/xcache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache/xcache.test.php | MIT |
function initialize(&$controller, $settings) {
foreach ($settings as $key => $value) {
if (is_numeric($key)) {
$this->{$value} = true;
} else {
$this->{$key} = $value;
}
}
} | initialize method
@param mixed $controller
@param mixed $settings
@access public
@return void | initialize | php | Datawalke/Coordino | cake/tests/cases/libs/controller/component.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/component.test.php | MIT |
function startup(&$controller) {
$this->testName = $controller->name;
} | startup method
@param mixed $controller
@access public
@return void | startup | php | Datawalke/Coordino | cake/tests/cases/libs/controller/component.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/component.test.php | MIT |
function initialize(&$controller, $settings) {
$this->Controller = $controller;
$this->Banana->testField = 'OrangeField';
$this->settings = $settings;
} | initialize method
@param mixed $controller
@access public
@return void | initialize | php | Datawalke/Coordino | cake/tests/cases/libs/controller/component.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/component.test.php | MIT |
function startup(&$controller) {
$controller->foo = 'pass';
} | startup method
@param Controller $controller
@return string
@access public | startup | php | Datawalke/Coordino | cake/tests/cases/libs/controller/component.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/component.test.php | MIT |
function startup(&$controller) {
$controller->bar = 'fail';
} | startup method
@param Controller $controller
@return string
@access public | startup | php | Datawalke/Coordino | cake/tests/cases/libs/controller/component.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/component.test.php | MIT |
function setUp() {
$this->_pluginPaths = App::path('plugins');
App::build(array(
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
} | setUp method
@access public
@return void | setUp | php | Datawalke/Coordino | cake/tests/cases/libs/controller/component.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/component.test.php | MIT |
function tearDown() {
App::build();
ClassRegistry::flush();
} | tearDown method
@access public
@return void | tearDown | php | Datawalke/Coordino | cake/tests/cases/libs/controller/component.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/component.test.php | MIT |
function testLoadComponents() {
$Controller =& new ComponentTestController();
$Controller->components = array('RequestHandler');
$Component =& new Component();
$Component->init($Controller);
$this->assertTrue(is_a($Controller->RequestHandler, 'RequestHandlerComponent'));
$Controller =& new ComponentTestController();
$Controller->plugin = 'test_plugin';
$Controller->components = array('RequestHandler', 'TestPluginComponent');
$Component =& new Component();
$Component->init($Controller);
$this->assertTrue(is_a($Controller->RequestHandler, 'RequestHandlerComponent'));
$this->assertTrue(is_a($Controller->TestPluginComponent, 'TestPluginComponentComponent'));
$this->assertTrue(is_a(
$Controller->TestPluginComponent->TestPluginOtherComponent,
'TestPluginOtherComponentComponent'
));
$this->assertFalse(isset($Controller->TestPluginOtherComponent));
$Controller =& new ComponentTestController();
$Controller->components = array('Security');
$Component =& new Component();
$Component->init($Controller);
$this->assertTrue(is_a($Controller->Security, 'SecurityComponent'));
$this->assertTrue(is_a($Controller->Security->Session, 'SessionComponent'));
$Controller =& new ComponentTestController();
$Controller->components = array('Security', 'Cookie', 'RequestHandler');
$Component =& new Component();
$Component->init($Controller);
$this->assertTrue(is_a($Controller->Security, 'SecurityComponent'));
$this->assertTrue(is_a($Controller->Security->RequestHandler, 'RequestHandlerComponent'));
$this->assertTrue(is_a($Controller->RequestHandler, 'RequestHandlerComponent'));
$this->assertTrue(is_a($Controller->Cookie, 'CookieComponent'));
} | testLoadComponents method
@access public
@return void | testLoadComponents | php | Datawalke/Coordino | cake/tests/cases/libs/controller/component.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/component.test.php | MIT |
function testComponentStartup() {
$Controller =& new ComponentTestController();
$Controller->components = array('Apple');
$Controller->uses = false;
$Controller->constructClasses();
$Controller->Component->initialize($Controller);
$Controller->beforeFilter();
$Controller->Component->startup($Controller);
$this->assertTrue(is_a($Controller->Apple, 'AppleComponent'));
$this->assertEqual($Controller->Apple->testName, 'ComponentTest');
$expected = !(defined('APP_CONTROLLER_EXISTS') && APP_CONTROLLER_EXISTS);
$this->assertEqual(isset($Controller->foo), $expected);
$this->assertFalse(isset($Controller->bar));
} | Tests Component::startup() and only running callbacks for components directly attached to
the controller.
@return void | testComponentStartup | php | Datawalke/Coordino | cake/tests/cases/libs/controller/component.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/component.test.php | MIT |
function testTriggerCallback() {
$Controller =& new ComponentTestController();
$Controller->components = array('ComponentMock');
$Controller->uses = null;
$Controller->constructClasses();
$Controller->ComponentMock->expectOnce('beforeRender');
$Controller->Component->triggerCallback('beforeRender', $Controller);
$Controller->ComponentMock->expectNever('beforeFilter');
$Controller->ComponentMock->enabled = false;
$Controller->Component->triggerCallback('beforeFilter', $Controller);
} | test that triggerCallbacks fires methods on all the components, and can trigger any method.
@return void | testTriggerCallback | php | Datawalke/Coordino | cake/tests/cases/libs/controller/component.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/component.test.php | MIT |
function testMultipleComponentInitialize() {
$Controller =& new ComponentTestController();
$Controller->uses = false;
$Controller->components = array('Orange', 'Banana');
$Controller->constructClasses();
$Controller->Component->initialize($Controller);
$this->assertEqual($Controller->Banana->testField, 'OrangeField');
$this->assertEqual($Controller->Orange->Banana->testField, 'OrangeField');
} | test a component being used more than once.
@return void | testMultipleComponentInitialize | php | Datawalke/Coordino | cake/tests/cases/libs/controller/component.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/component.test.php | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.