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 testSet() {
$_cacheSet = Cache::set();
Cache::set(array('duration' => '+1 year'));
$data = Cache::read('test_cache');
$this->assertFalse($data);
$data = 'this is just a simple test of the cache system';
$write = Cache::write('test_cache', $data);
$this->assertTrue($write);
Cache::set(array('duration' => '+1 year'));
$data = Cache::read('test_cache');
$this->assertEqual($data, 'this is just a simple test of the cache system');
Cache::delete('test_cache');
$global = Cache::settings();
Cache::set($_cacheSet);
} | testSet method
@access public
@return void | testSet | php | Datawalke/Coordino | cake/tests/cases/libs/cache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache.test.php | MIT |
function startTest() {
$streams = CakeLog::configured();
foreach ($streams as $stream) {
CakeLog::drop($stream);
}
} | Start test callback, clears all streams enabled.
@return void | startTest | php | Datawalke/Coordino | cake/tests/cases/libs/cake_log.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_log.test.php | MIT |
function testImportingLoggers() {
App::build(array(
'libs' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
), true);
$result = CakeLog::config('libtest', array(
'engine' => 'TestAppLog'
));
$this->assertTrue($result);
$this->assertEqual(CakeLog::configured(), array('libtest'));
$result = CakeLog::config('plugintest', array(
'engine' => 'TestPlugin.TestPluginLog'
));
$this->assertTrue($result);
$this->assertEqual(CakeLog::configured(), array('libtest', 'plugintest'));
App::build();
} | test importing loggers from app/libs and plugins.
@return void | testImportingLoggers | php | Datawalke/Coordino | cake/tests/cases/libs/cake_log.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_log.test.php | MIT |
function testImportingLoggerFailure() {
$this->expectError('Missing logger classname');
CakeLog::config('fail', array());
$this->expectError('Could not load logger class born to fail');
CakeLog::config('fail', array('engine' => 'born to fail'));
$this->expectError('logger class stdClass does not implement a write method.');
CakeLog::config('fail', array('engine' => 'stdClass'));
} | test all the errors from failed logger imports
@return void | testImportingLoggerFailure | php | Datawalke/Coordino | cake/tests/cases/libs/cake_log.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_log.test.php | MIT |
function testAutoConfig() {
@unlink(LOGS . 'error.log');
CakeLog::write(LOG_WARNING, 'Test warning');
$this->assertTrue(file_exists(LOGS . 'error.log'));
$result = CakeLog::configured();
$this->assertEqual($result, array('default'));
unlink(LOGS . 'error.log');
} | Test that CakeLog autoconfigures itself to use a FileLogger with the LOGS dir.
When no streams are there.
@return void | testAutoConfig | php | Datawalke/Coordino | cake/tests/cases/libs/cake_log.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_log.test.php | MIT |
function testConfig() {
CakeLog::config('file', array(
'engine' => 'FileLog',
'path' => LOGS
));
$result = CakeLog::configured();
$this->assertEqual($result, array('file'));
@unlink(LOGS . 'error.log');
CakeLog::write(LOG_WARNING, 'Test warning');
$this->assertTrue(file_exists(LOGS . 'error.log'));
$result = file_get_contents(LOGS . 'error.log');
$this->assertPattern('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Warning: Test warning/', $result);
unlink(LOGS . 'error.log');
} | test configuring log streams
@return void | testConfig | php | Datawalke/Coordino | cake/tests/cases/libs/cake_log.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_log.test.php | MIT |
function testDrop() {
CakeLog::config('file', array(
'engine' => 'FileLog',
'path' => LOGS
));
$result = CakeLog::configured();
$this->assertEqual($result, array('file'));
CakeLog::drop('file');
$result = CakeLog::configured();
$this->assertEqual($result, array());
} | explict tests for drop()
@return void | testDrop | php | Datawalke/Coordino | cake/tests/cases/libs/cake_log.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_log.test.php | MIT |
function testLogFileWriting() {
@unlink(LOGS . 'error.log');
$result = CakeLog::write(LOG_WARNING, 'Test warning');
$this->assertTrue($result);
$this->assertTrue(file_exists(LOGS . 'error.log'));
unlink(LOGS . 'error.log');
CakeLog::write(LOG_WARNING, 'Test warning 1');
CakeLog::write(LOG_WARNING, 'Test warning 2');
$result = file_get_contents(LOGS . 'error.log');
$this->assertPattern('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Warning: Test warning 1/', $result);
$this->assertPattern('/2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Warning: Test warning 2$/', $result);
unlink(LOGS . 'error.log');
} | testLogFileWriting method
@access public
@return void | testLogFileWriting | php | Datawalke/Coordino | cake/tests/cases/libs/cake_log.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_log.test.php | MIT |
function testLoggingWithErrorHandling() {
@unlink(LOGS . 'debug.log');
Configure::write('log', E_ALL & ~E_DEPRECATED & ~E_STRICT);
Configure::write('debug', 0);
set_error_handler(array('CakeLog', 'handleError'));
$out .= '';
$result = file(LOGS . 'debug.log');
$this->assertEqual(count($result), 1);
$this->assertPattern(
'/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} Notice: Notice \(8\): Undefined variable:\s+out in \[.+ line \d+\]$/',
$result[0]
);
@unlink(LOGS . 'debug.log');
} | Test logging with the error handler.
@return void | testLoggingWithErrorHandling | php | Datawalke/Coordino | cake/tests/cases/libs/cake_log.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_log.test.php | MIT |
function startCase() {
// Make sure garbage colector will be called
$this->__gc_divisor = ini_get('session.gc_divisor');
ini_set('session.gc_divisor', '1');
} | startCase method
@access public
@return void | startCase | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function endCase() {
// Revert to the default setting
ini_set('session.gc_divisor', $this->__gc_divisor);
} | endCase method
@access public
@return void | endCase | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function setUp() {
$this->Session =& new CakeSession();
$this->Session->start();
$this->Session->_checkValid();
} | setUp method
@access public
@return void | setUp | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function tearDown() {
unset($_SESSION);
session_destroy();
} | tearDown method
@access public
@return void | tearDown | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function testCheck() {
$this->Session->write('SessionTestCase', 'value');
$this->assertTrue($this->Session->check('SessionTestCase'));
$this->assertFalse($this->Session->check('NotExistingSessionTestCase'), false);
} | testCheck method
@access public
@return void | testCheck | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function testSimpleRead() {
$this->Session->write('testing', '1,2,3');
$result = $this->Session->read('testing');
$this->assertEqual($result, '1,2,3');
$this->Session->write('testing', array('1' => 'one', '2' => 'two','3' => 'three'));
$result = $this->Session->read('testing.1');
$this->assertEqual($result, 'one');
$result = $this->Session->read('testing');
$this->assertEqual($result, array('1' => 'one', '2' => 'two', '3' => 'three'));
$result = $this->Session->read();
$this->assertTrue(isset($result['testing']));
$this->assertTrue(isset($result['Config']));
$this->assertTrue(isset($result['Config']['userAgent']));
$this->Session->write('This.is.a.deep.array.my.friend', 'value');
$result = $this->Session->read('This.is.a.deep.array.my.friend');
$this->assertEqual('value', $result);
} | testSimpleRead method
@access public
@return void | testSimpleRead | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function testId() {
$expected = session_id();
$result = $this->Session->id();
$this->assertEqual($result, $expected);
$this->Session->id('MySessionId');
$result = $this->Session->id();
$this->assertEqual($result, 'MySessionId');
} | testId method
@access public
@return void | testId | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function testStarted() {
$this->assertTrue($this->Session->started());
unset($_SESSION);
$_SESSION = null;
$this->assertFalse($this->Session->started());
$this->assertTrue($this->Session->start());
$session = new CakeSession(null, false);
$this->assertTrue($session->started());
unset($session);
} | testStarted method
@access public
@return void | testStarted | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function testError() {
$this->Session->read('Does.not.exist');
$result = $this->Session->error();
$this->assertEqual($result, "Does.not.exist doesn't exist");
$this->Session->delete('Failing.delete');
$result = $this->Session->error();
$this->assertEqual($result, "Failing.delete doesn't exist");
} | testError method
@access public
@return void | testError | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function testDelete() {
$this->assertTrue($this->Session->write('Delete.me', 'Clearing out'));
$this->assertTrue($this->Session->delete('Delete.me'));
$this->assertFalse($this->Session->check('Delete.me'));
$this->assertTrue($this->Session->check('Delete'));
$this->assertTrue($this->Session->write('Clearing.sale', 'everything must go'));
$this->assertTrue($this->Session->delete('Clearing'));
$this->assertFalse($this->Session->check('Clearing.sale'));
$this->assertFalse($this->Session->check('Clearing'));
} | testDel method
@access public
@return void | testDelete | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function testWatchVar() {
$this->assertFalse($this->Session->watch(null));
$this->Session->write('Watching', "I'm watching you");
$this->Session->watch('Watching');
$this->expectError('Writing session key {Watching}: "They found us!"');
$this->Session->write('Watching', 'They found us!');
$this->expectError('Deleting session key {Watching}');
$this->Session->delete('Watching');
$this->assertFalse($this->Session->watch('Invalid.key'));
} | testWatchVar method
@access public
@return void | testWatchVar | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function testIgnore() {
$this->Session->write('Watching', "I'm watching you");
$this->Session->watch('Watching');
$this->Session->ignore('Watching');
$this->assertTrue($this->Session->write('Watching', 'They found us!'));
} | testIgnore method
@access public
@return void | testIgnore | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function testDestroy() {
$this->Session->write('bulletProof', 'invicible');
$id = $this->Session->id();
$this->Session->destroy();
$this->assertFalse($this->Session->check('bulletProof'));
$this->assertNotEqual($id, $this->Session->id());
$this->assertTrue($this->Session->started());
$this->Session->cookieLifeTime = 'test';
$this->Session->destroy();
$this->assertNotEqual('test', $this->Session->cookieLifeTime);
} | testDestroy method
@access public
@return void | testDestroy | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function testCheckingSavedEmpty() {
$this->assertTrue($this->Session->write('SessionTestCase', 0));
$this->assertTrue($this->Session->check('SessionTestCase'));
$this->assertTrue($this->Session->write('SessionTestCase', '0'));
$this->assertTrue($this->Session->check('SessionTestCase'));
$this->assertTrue($this->Session->write('SessionTestCase', false));
$this->assertTrue($this->Session->check('SessionTestCase'));
$this->assertTrue($this->Session->write('SessionTestCase', null));
$this->assertFalse($this->Session->check('SessionTestCase'));
} | testCheckingSavedEmpty method
@access public
@return void | testCheckingSavedEmpty | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function testCheckKeyWithSpaces() {
$this->assertTrue($this->Session->write('Session Test', "test"));
$this->assertEqual($this->Session->check('Session Test'), 'test');
$this->Session->delete('Session Test');
$this->assertTrue($this->Session->write('Session Test.Test Case', "test"));
$this->assertTrue($this->Session->check('Session Test.Test Case'));
} | testCheckKeyWithSpaces method
@access public
@return void | testCheckKeyWithSpaces | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function testReadingSavedEmpty() {
$this->Session->write('SessionTestCase', 0);
$this->assertEqual($this->Session->read('SessionTestCase'), 0);
$this->Session->write('SessionTestCase', '0');
$this->assertEqual($this->Session->read('SessionTestCase'), '0');
$this->assertFalse($this->Session->read('SessionTestCase') === 0);
$this->Session->write('SessionTestCase', false);
$this->assertFalse($this->Session->read('SessionTestCase'));
$this->Session->write('SessionTestCase', null);
$this->assertEqual($this->Session->read('SessionTestCase'), null);
} | testReadingSavedEmpty method
@access public
@return void | testReadingSavedEmpty | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function testCheckUserAgentFalse() {
Configure::write('Session.checkAgent', false);
$this->Session->_userAgent = md5('http://randomdomainname.com' . Configure::read('Security.salt'));
$this->assertTrue($this->Session->valid());
} | testCheckUserAgentFalse method
@access public
@return void | testCheckUserAgentFalse | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function testCheckUserAgentTrue() {
Configure::write('Session.checkAgent', true);
$this->Session->_userAgent = md5('http://randomdomainname.com' . Configure::read('Security.salt'));
$this->assertFalse($this->Session->valid());
} | testCheckUserAgentTrue method
@access public
@return void | testCheckUserAgentTrue | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function testReadAndWriteWithCakeStorage() {
unset($_SESSION);
session_destroy();
ini_set('session.save_handler', 'files');
Configure::write('Session.save', 'cake');
$this->setUp();
$this->Session->write('SessionTestCase', 0);
$this->assertEqual($this->Session->read('SessionTestCase'), 0);
$this->Session->write('SessionTestCase', '0');
$this->assertEqual($this->Session->read('SessionTestCase'), '0');
$this->assertFalse($this->Session->read('SessionTestCase') === 0);
$this->Session->write('SessionTestCase', false);
$this->assertFalse($this->Session->read('SessionTestCase'));
$this->Session->write('SessionTestCase', null);
$this->assertEqual($this->Session->read('SessionTestCase'), null);
$this->Session->write('SessionTestCase', 'This is a Test');
$this->assertEqual($this->Session->read('SessionTestCase'), 'This is a Test');
$this->Session->write('SessionTestCase', 'This is a Test');
$this->Session->write('SessionTestCase', 'This was updated');
$this->assertEqual($this->Session->read('SessionTestCase'), 'This was updated');
$this->Session->destroy();
$this->assertFalse($this->Session->read('SessionTestCase'));
} | testReadAndWriteWithDatabaseStorage method
@access public
@return void | testReadAndWriteWithCakeStorage | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function testReadAndWriteWithCacheStorage() {
unset($_SESSION);
session_destroy();
ini_set('session.save_handler', 'files');
Configure::write('Session.save', 'cache');
$this->setUp();
$this->Session->write('SessionTestCase', 0);
$this->assertEqual($this->Session->read('SessionTestCase'), 0);
$this->Session->write('SessionTestCase', '0');
$this->assertEqual($this->Session->read('SessionTestCase'), '0');
$this->assertFalse($this->Session->read('SessionTestCase') === 0);
$this->Session->write('SessionTestCase', false);
$this->assertFalse($this->Session->read('SessionTestCase'));
$this->Session->write('SessionTestCase', null);
$this->assertEqual($this->Session->read('SessionTestCase'), null);
$this->Session->write('SessionTestCase', 'This is a Test');
$this->assertEqual($this->Session->read('SessionTestCase'), 'This is a Test');
$this->Session->write('SessionTestCase', 'This is a Test');
$this->Session->write('SessionTestCase', 'This was updated');
$this->assertEqual($this->Session->read('SessionTestCase'), 'This was updated');
$this->Session->destroy();
$this->assertFalse($this->Session->read('SessionTestCase'));
} | testReadAndWriteWithDatabaseStorage method
@access public
@return void | testReadAndWriteWithCacheStorage | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function testReadAndWriteWithDatabaseStorage() {
unset($_SESSION);
session_destroy();
Configure::write('Session.table', 'sessions');
Configure::write('Session.model', 'Session');
Configure::write('Session.database', 'test_suite');
Configure::write('Session.save', 'database');
$this->setUp();
$this->Session->write('SessionTestCase', 0);
$this->assertEqual($this->Session->read('SessionTestCase'), 0);
$this->Session->write('SessionTestCase', '0');
$this->assertEqual($this->Session->read('SessionTestCase'), '0');
$this->assertFalse($this->Session->read('SessionTestCase') === 0);
$this->Session->write('SessionTestCase', false);
$this->assertFalse($this->Session->read('SessionTestCase'));
$this->Session->write('SessionTestCase', null);
$this->assertEqual($this->Session->read('SessionTestCase'), null);
$this->Session->write('SessionTestCase', 'This is a Test');
$this->assertEqual($this->Session->read('SessionTestCase'), 'This is a Test');
$this->Session->write('SessionTestCase', 'Some additional data');
$this->assertEqual($this->Session->read('SessionTestCase'), 'Some additional data');
$this->Session->destroy();
$this->assertFalse($this->Session->read('SessionTestCase'));
session_write_close();
unset($_SESSION);
ini_set('session.save_handler', 'files');
Configure::write('Session.save', 'php');
$this->setUp();
} | testReadAndWriteWithDatabaseStorage method
@access public
@return void | testReadAndWriteWithDatabaseStorage | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function testDatabaseStorageEmptySessionId() {
unset($_SESSION);
session_destroy();
Configure::write('Session.table', 'sessions');
Configure::write('Session.model', 'Session');
Configure::write('Session.database', 'test_suite');
Configure::write('Session.save', 'database');
$this->setUp();
$id = $this->Session->id();
$this->Session->id = '';
session_id('');
$this->Session->write('SessionTestCase', 'This is a Test');
$this->assertEqual($this->Session->read('SessionTestCase'), 'This is a Test');
session_write_close();
unset($_SESSION);
ini_set('session.save_handler', 'files');
Configure::write('Session.save', 'php');
session_id($id);
$this->setUp();
} | testReadAndWriteWithDatabaseStorage method
@access public
@return void | testDatabaseStorageEmptySessionId | php | Datawalke/Coordino | cake/tests/cases/libs/cake_session.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_session.test.php | MIT |
function setUp() {
$this->Socket = new CakeSocket();
} | setUp method
@access public
@return void | setUp | php | Datawalke/Coordino | cake/tests/cases/libs/cake_socket.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_socket.test.php | MIT |
function testConstruct() {
$this->Socket->__construct();
$baseConfig = $this->Socket->_baseConfig;
$this->assertIdentical($baseConfig, array(
'persistent' => false,
'host' => 'localhost',
'protocol' => 'tcp',
'port' => 80,
'timeout' => 30
));
$this->Socket->reset();
$this->Socket->__construct(array('host' => 'foo-bar'));
$baseConfig['host'] = 'foo-bar';
$baseConfig['protocol'] = getprotobyname($baseConfig['protocol']);
$this->assertIdentical($this->Socket->config, $baseConfig);
$this->Socket = new CakeSocket(array('host' => 'www.cakephp.org', 'port' => 23, 'protocol' => 'udp'));
$baseConfig = $this->Socket->_baseConfig;
$baseConfig['host'] = 'www.cakephp.org';
$baseConfig['port'] = 23;
$baseConfig['protocol'] = 17;
$this->assertIdentical($this->Socket->config, $baseConfig);
} | testConstruct method
@access public
@return void | testConstruct | php | Datawalke/Coordino | cake/tests/cases/libs/cake_socket.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_socket.test.php | MIT |
function testSocketConnection() {
$this->assertFalse($this->Socket->connected);
$this->Socket->disconnect();
$this->assertFalse($this->Socket->connected);
$this->Socket->connect();
$this->assertTrue($this->Socket->connected);
$this->Socket->connect();
$this->assertTrue($this->Socket->connected);
$this->Socket->disconnect();
$config = array('persistent' => true);
$this->Socket = new CakeSocket($config);
$this->Socket->connect();
$this->assertTrue($this->Socket->connected);
} | testSocketConnection method
@access public
@return void | testSocketConnection | php | Datawalke/Coordino | cake/tests/cases/libs/cake_socket.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_socket.test.php | MIT |
function testSocketHost() {
$this->Socket = new CakeSocket();
$this->Socket->connect();
$this->assertEqual($this->Socket->address(), '127.0.0.1');
$this->assertEqual(gethostbyaddr('127.0.0.1'), $this->Socket->host());
$this->assertEqual($this->Socket->lastError(), null);
$this->assertTrue(in_array('127.0.0.1', $this->Socket->addresses()));
$this->Socket = new CakeSocket(array('host' => '127.0.0.1'));
$this->Socket->connect();
$this->assertEqual($this->Socket->address(), '127.0.0.1');
$this->assertEqual(gethostbyaddr('127.0.0.1'), $this->Socket->host());
$this->assertEqual($this->Socket->lastError(), null);
$this->assertTrue(in_array('127.0.0.1', $this->Socket->addresses()));
} | testSocketHost method
@access public
@return void | testSocketHost | php | Datawalke/Coordino | cake/tests/cases/libs/cake_socket.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_socket.test.php | MIT |
function testSocketWriting() {
$request = "GET / HTTP/1.1\r\nConnection: close\r\n\r\n";
$this->assertTrue($this->Socket->write($request));
} | testSocketWriting method
@access public
@return void | testSocketWriting | php | Datawalke/Coordino | cake/tests/cases/libs/cake_socket.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_socket.test.php | MIT |
function testSocketReading() {
$this->Socket = new CakeSocket(array('timeout' => 5));
$this->Socket->connect();
$this->assertEqual($this->Socket->read(26), null);
$config = array('host' => 'www.cakephp.org', 'timeout' => 1);
$this->Socket = new CakeSocket($config);
$this->assertTrue($this->Socket->connect());
$this->assertFalse($this->Socket->read(1024 * 1024));
$this->assertEqual($this->Socket->lastError(), '2: ' . __('Connection timed out', true));
$config = array('host' => 'www.cakephp.org', 'timeout' => 30);
$this->Socket = new CakeSocket($config);
$this->assertTrue($this->Socket->connect());
$this->assertEqual($this->Socket->read(26), null);
$this->assertEqual($this->Socket->lastError(), null);
} | testSocketReading method
@access public
@return void | testSocketReading | php | Datawalke/Coordino | cake/tests/cases/libs/cake_socket.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_socket.test.php | MIT |
function testLastError() {
$this->Socket = new CakeSocket();
$this->Socket->setLastError(4, 'some error here');
$this->assertEqual($this->Socket->lastError(), '4: some error here');
} | testLastError method
@access public
@return void | testLastError | php | Datawalke/Coordino | cake/tests/cases/libs/cake_socket.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_socket.test.php | MIT |
function testReset() {
$config = array(
'persistent' => true,
'host' => '127.0.0.1',
'protocol' => 'udp',
'port' => 80,
'timeout' => 20
);
$anotherSocket = new CakeSocket($config);
$anotherSocket->reset();
$this->assertEqual(array(), $anotherSocket->config);
} | testReset method
@access public
@return void | testReset | php | Datawalke/Coordino | cake/tests/cases/libs/cake_socket.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_socket.test.php | MIT |
function setReporter(&$reporter) {
$this->_reporter = &$reporter;
} | Feed a Mocked Reporter to the subject case
prevents its pass/fails from affecting the real test
@param string $reporter
@access public
@return void | setReporter | php | Datawalke/Coordino | cake/tests/cases/libs/cake_test_case.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_test_case.test.php | MIT |
function testAssertTagsQuotes() {
$input = '<a href="/test.html" class="active">My link</a>';
$pattern = array(
'a' => array('href' => '/test.html', 'class' => 'active'),
'My link',
'/a'
);
$this->assertTrue($this->Case->assertTags($input, $pattern), 'Double quoted attributes %s');
$input = "<a href='/test.html' class='active'>My link</a>";
$pattern = array(
'a' => array('href' => '/test.html', 'class' => 'active'),
'My link',
'/a'
);
$this->assertTrue($this->Case->assertTags($input, $pattern), 'Single quoted attributes %s');
$input = "<a href='/test.html' class='active'>My link</a>";
$pattern = array(
'a' => array('href' => 'preg:/.*\.html/', 'class' => 'active'),
'My link',
'/a'
);
$this->assertTrue($this->Case->assertTags($input, $pattern), 'Single quoted attributes %s');
} | test that assertTags knows how to handle correct quoting.
@return void | testAssertTagsQuotes | php | Datawalke/Coordino | cake/tests/cases/libs/cake_test_case.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_test_case.test.php | MIT |
function testGetTests() {
$result = $this->Case->getTests();
$this->assertEqual(array_slice($result, 0, 2), array('start', 'startCase'));
$this->assertEqual(array_slice($result, -2), array('endCase', 'end'));
} | testGetTests Method
@return void
@access public | testGetTests | php | Datawalke/Coordino | cake/tests/cases/libs/cake_test_case.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_test_case.test.php | MIT |
function setUp() {
$this->criticDb =& new FixtureMockDboSource();
$this->criticDb->fullDebug = true;
} | setUp method
@access public
@return void | setUp | php | Datawalke/Coordino | cake/tests/cases/libs/cake_test_fixture.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_test_fixture.test.php | MIT |
function testInitDbPrefix() {
$this->_initDb();
$Source =& new CakeTestFixtureTestFixture();
$Source->create($this->db);
$Source->insert($this->db);
$Fixture =& new CakeTestFixtureImportFixture();
$expected = array('id', 'name', 'created');
$this->assertEqual(array_keys($Fixture->fields), $expected);
$db =& ConnectionManager::getDataSource('test_suite');
$config = $db->config;
$config['prefix'] = 'fixture_test_suite_';
ConnectionManager::create('fixture_test_suite', $config);
$Fixture->fields = $Fixture->records = null;
$Fixture->import = array('table' => 'fixture_tests', 'connection' => 'test_suite', 'records' => true);
$Fixture->init();
$this->assertEqual(count($Fixture->records), count($Source->records));
$Fixture =& new CakeTestFixtureImportFixture();
$Fixture->fields = $Fixture->records = $Fixture->table = null;
$Fixture->import = array('model' => 'FixtureImportTestModel', 'connection' => 'test_suite');
$Fixture->init();
$this->assertEqual(array_keys($Fixture->fields), array('id', 'name', 'created'));
$this->assertEqual($Fixture->table, 'fixture_tests');
$keys = array_flip(ClassRegistry::keys());
$this->assertFalse(array_key_exists('fixtureimporttestmodel', $keys));
$Source->drop($this->db);
} | test that init() correctly sets the fixture table when the connection or model have prefixes defined.
@return void | testInitDbPrefix | php | Datawalke/Coordino | cake/tests/cases/libs/cake_test_fixture.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_test_fixture.test.php | MIT |
function testInitDbPrefixDuplication() {
$this->_initDb();
$backPrefix = $this->db->config['prefix'];
$this->db->config['prefix'] = 'cake_fixture_test_';
$Source =& new CakeTestFixtureTestFixture();
$Source->create($this->db);
$Source->insert($this->db);
$Fixture =& new CakeTestFixtureImportFixture();
$Fixture->fields = $Fixture->records = $Fixture->table = null;
$Fixture->import = array('model' => 'FixtureImportTestModel', 'connection' => 'test_suite');
$Fixture->init();
$this->assertEqual(array_keys($Fixture->fields), array('id', 'name', 'created'));
$this->assertEqual($Fixture->table, 'fixture_tests');
$Source->drop($this->db);
$this->db->config['prefix'] = $backPrefix;
} | test that fixtures don't duplicate the test db prefix.
@return void | testInitDbPrefixDuplication | php | Datawalke/Coordino | cake/tests/cases/libs/cake_test_fixture.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_test_fixture.test.php | MIT |
function testInitModelTablePrefix() {
$this->_initDb();
$hasPrefix = !empty($this->db->config['prefix']);
if ($this->skipIf($hasPrefix, 'Cannot run this test, you have a database connection prefix.')) {
return;
}
$Source =& new CakeTestFixtureTestFixture();
$Source->create($this->db);
$Source->insert($this->db);
$Fixture =& new CakeTestFixtureImportFixture();
unset($Fixture->table);
$Fixture->fields = $Fixture->records = null;
$Fixture->import = array('model' => 'FixturePrefixTest', 'connection' => 'test_suite', 'records' => false);
$Fixture->init();
$this->assertEqual($Fixture->table, 'fixture_tests');
$keys = array_flip(ClassRegistry::keys());
$this->assertFalse(array_key_exists('fixtureimporttestmodel', $keys));
$Source->drop($this->db);
} | test init with a model that has a tablePrefix declared.
@return void | testInitModelTablePrefix | php | Datawalke/Coordino | cake/tests/cases/libs/cake_test_fixture.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_test_fixture.test.php | MIT |
function testImportWithRecords() {
$this->_initDb();
$defaultDb =& ConnectionManager::getDataSource('default');
$testSuiteDb =& ConnectionManager::getDataSource('test_suite');
$defaultConfig = $defaultDb->config;
$testSuiteConfig = $testSuiteDb->config;
ConnectionManager::create('new_test_suite', array_merge($testSuiteConfig, array('prefix' => 'new_' . $testSuiteConfig['prefix'])));
$newTestSuiteDb =& ConnectionManager::getDataSource('new_test_suite');
$Source =& new CakeTestFixtureTestFixture();
$Source->create($newTestSuiteDb);
$Source->insert($newTestSuiteDb);
$defaultDb->config = $newTestSuiteDb->config;
$Fixture =& new CakeTestFixtureDefaultImportFixture();
$Fixture->fields = $Fixture->records = null;
$Fixture->import = array(
'model' => 'FixtureImportTestModel', 'connection' => 'new_test_suite', 'records' => true
);
$Fixture->init();
$this->assertEqual(array_keys($Fixture->fields), array('id', 'name', 'created'));
$this->assertFalse(empty($Fixture->records[0]), 'No records loaded on importing fixture.');
$this->assertTrue(isset($Fixture->records[0]['name']), 'No name loaded for first record');
$defaultDb->config = $defaultConfig;
$Source->drop($newTestSuiteDb);
} | test that importing with records works. Make sure to try with postgres as its
handling of aliases is a workaround at best.
@return void | testImportWithRecords | php | Datawalke/Coordino | cake/tests/cases/libs/cake_test_fixture.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_test_fixture.test.php | MIT |
function testCreate() {
$Fixture =& new CakeTestFixtureTestFixture();
$this->criticDb->expectAtLeastOnce('execute');
$this->criticDb->expectAtLeastOnce('createSchema');
$return = $Fixture->create($this->criticDb);
$this->assertTrue($this->criticDb->fullDebug);
$this->assertTrue($return);
unset($Fixture->fields);
$return = $Fixture->create($this->criticDb);
$this->assertFalse($return);
} | test create method
@access public
@return void | testCreate | php | Datawalke/Coordino | cake/tests/cases/libs/cake_test_fixture.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_test_fixture.test.php | MIT |
function testInsert() {
$Fixture =& new CakeTestFixtureTestFixture();
$this->criticDb->insertMulti = array();
$return = $Fixture->insert($this->criticDb);
$this->assertTrue(!empty($this->criticDb->insertMulti));
$this->assertTrue($this->criticDb->fullDebug);
$this->assertTrue($return);
$this->assertEqual('fixture_tests', $this->criticDb->insertMulti['table']);
$this->assertEqual(array('name', 'created'), $this->criticDb->insertMulti['fields']);
$expected = array(
'(\'Gandalf\', \'2009-04-28 19:20:00\')',
'(\'Captain Picard\', \'2009-04-28 19:20:00\')',
'(\'Chewbacca\', \'2009-04-28 19:20:00\')'
);
$this->assertEqual($expected, $this->criticDb->insertMulti['values']);
} | test the insert method
@access public
@return void | testInsert | php | Datawalke/Coordino | cake/tests/cases/libs/cake_test_fixture.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_test_fixture.test.php | MIT |
function testInsertStrings() {
$Fixture =& new StringsTestFixture();
$this->criticDb->insertMulti = array();
$return = $Fixture->insert($this->criticDb);
$this->assertTrue(!empty($this->criticDb->insertMulti));
$this->assertTrue($this->criticDb->fullDebug);
$this->assertTrue($return);
$this->assertEqual('strings', $this->criticDb->insertMulti['table']);
$this->assertEqual(array('name', 'email', 'age'), $this->criticDb->insertMulti['fields']);
$expected = array(
'(\'John Doe\', \'[email protected]\', 20)',
'(\'Jane Doe\', \'[email protected]\', 30)',
'(\'Mark Doe\', \'[email protected]\', NULL)',
);
$this->assertEqual($expected, $this->criticDb->insertMulti['values']);
} | test the insert method
@access public
@return void | testInsertStrings | php | Datawalke/Coordino | cake/tests/cases/libs/cake_test_fixture.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_test_fixture.test.php | MIT |
function testDrop() {
$Fixture =& new CakeTestFixtureTestFixture();
$this->criticDb->setReturnValueAt(0, 'execute', true);
$this->criticDb->expectAtLeastOnce('execute');
$this->criticDb->expectAtLeastOnce('dropSchema');
$return = $Fixture->drop($this->criticDb);
$this->assertTrue($this->criticDb->fullDebug);
$this->assertTrue($return);
$this->criticDb->setReturnValueAt(1, 'execute', false);
$return = $Fixture->drop($this->criticDb);
$this->assertFalse($return);
unset($Fixture->fields);
$return = $Fixture->drop($this->criticDb);
$this->assertFalse($return);
} | Test the drop method
@access public
@return void | testDrop | php | Datawalke/Coordino | cake/tests/cases/libs/cake_test_fixture.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_test_fixture.test.php | MIT |
function testTruncate() {
$Fixture =& new CakeTestFixtureTestFixture();
$this->criticDb->expectAtLeastOnce('truncate');
$Fixture->truncate($this->criticDb);
$this->assertTrue($this->criticDb->fullDebug);
} | Test the truncate method.
@access public
@return void | testTruncate | php | Datawalke/Coordino | cake/tests/cases/libs/cake_test_fixture.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cake_test_fixture.test.php | MIT |
function testAddModel() {
if (PHP5) {
$Tag = ClassRegistry::init('RegisterArticleTag');
} else {
$Tag =& ClassRegistry::init('RegisterArticleTag');
}
$this->assertTrue(is_a($Tag, 'RegisterArticleTag'));
$TagCopy = ClassRegistry::isKeySet('RegisterArticleTag');
$this->assertTrue($TagCopy);
$Tag->name = 'SomeNewName';
if (PHP5) {
$TagCopy = ClassRegistry::getObject('RegisterArticleTag');
} else {
$TagCopy =& ClassRegistry::getObject('RegisterArticleTag');
}
$this->assertTrue(is_a($TagCopy, 'RegisterArticleTag'));
$this->assertIdentical($Tag, $TagCopy);
if (PHP5) {
$NewTag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag'));
} else {
$NewTag =& ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag'));
}
$this->assertTrue(is_a($Tag, 'RegisterArticleTag'));
if (PHP5) {
$NewTagCopy = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag'));
} else {
$NewTagCopy =& ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag'));
}
$this->assertNotIdentical($Tag, $NewTag);
$this->assertIdentical($NewTag, $NewTagCopy);
$NewTag->name = 'SomeOtherName';
$this->assertNotIdentical($Tag, $NewTag);
$this->assertIdentical($NewTag, $NewTagCopy);
$Tag->name = 'SomeOtherName';
$this->assertNotIdentical($Tag, $NewTag);
$this->assertTrue($TagCopy->name === 'SomeOtherName');
if (PHP5) {
$User = ClassRegistry::init(array('class' => 'RegisterUser', 'alias' => 'User', 'table' => false));
} else {
$User =& ClassRegistry::init(array('class' => 'RegisterUser', 'alias' => 'User', 'table' => false));
}
$this->assertTrue(is_a($User, 'AppModel'));
if (PHP5) {
$UserCopy = ClassRegistry::init(array('class' => 'RegisterUser', 'alias' => 'User', 'table' => false));
} else {
$UserCopy =& ClassRegistry::init(array('class' => 'RegisterUser', 'alias' => 'User', 'table' => false));
}
$this->assertTrue(is_a($UserCopy, 'AppModel'));
$this->assertIdentical($User, $UserCopy);
if (PHP5) {
$Category = ClassRegistry::init(array('class' => 'RegisterCategory'));
} else {
$Category =& ClassRegistry::init(array('class' => 'RegisterCategory'));
}
$this->assertTrue(is_a($Category, 'RegisterCategory'));
if (PHP5) {
$ParentCategory = ClassRegistry::init(array('class' => 'RegisterCategory', 'alias' => 'ParentCategory'));
} else {
$ParentCategory =& ClassRegistry::init(array('class' => 'RegisterCategory', 'alias' => 'ParentCategory'));
}
$this->assertTrue(is_a($ParentCategory, 'RegisterCategory'));
$this->assertNotIdentical($Category, $ParentCategory);
$this->assertNotEqual($Category->alias, $ParentCategory->alias);
$this->assertEqual('RegisterCategory', $Category->alias);
$this->assertEqual('ParentCategory', $ParentCategory->alias);
} | testAddModel method
@access public
@return void | testAddModel | php | Datawalke/Coordino | cake/tests/cases/libs/class_registry.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/class_registry.test.php | MIT |
function testClassRegistryFlush() {
$ArticleTag = ClassRegistry::getObject('RegisterArticleTag');
$this->assertTrue(is_a($ArticleTag, 'RegisterArticleTag'));
ClassRegistry::flush();
$NoArticleTag = ClassRegistry::isKeySet('RegisterArticleTag');
$this->assertFalse($NoArticleTag);
$this->assertTrue(is_a($ArticleTag, 'RegisterArticleTag'));
} | testClassRegistryFlush method
@access public
@return void | testClassRegistryFlush | php | Datawalke/Coordino | cake/tests/cases/libs/class_registry.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/class_registry.test.php | MIT |
function testAddMultipleModels() {
$Article = ClassRegistry::isKeySet('Article');
$this->assertFalse($Article);
$Featured = ClassRegistry::isKeySet('Featured');
$this->assertFalse($Featured);
$Tag = ClassRegistry::isKeySet('Tag');
$this->assertFalse($Tag);
$models = array(array('class' => 'RegisterArticle', 'alias' => 'Article'),
array('class' => 'RegisterArticleFeatured', 'alias' => 'Featured'),
array('class' => 'RegisterArticleTag', 'alias' => 'Tag'));
$added = ClassRegistry::init($models);
$this->assertTrue($added);
$Article = ClassRegistry::isKeySet('Article');
$this->assertTrue($Article);
$Featured = ClassRegistry::isKeySet('Featured');
$this->assertTrue($Featured);
$Tag = ClassRegistry::isKeySet('Tag');
$this->assertTrue($Tag);
$Article = ClassRegistry::getObject('Article');
$this->assertTrue(is_a($Article, 'RegisterArticle'));
$Featured = ClassRegistry::getObject('Featured');
$this->assertTrue(is_a($Featured, 'RegisterArticleFeatured'));
$Tag = ClassRegistry::getObject('Tag');
$this->assertTrue(is_a($Tag, 'RegisterArticleTag'));
} | testAddMultipleModels method
@access public
@return void | testAddMultipleModels | php | Datawalke/Coordino | cake/tests/cases/libs/class_registry.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/class_registry.test.php | MIT |
function testPluginAppModel() {
$TestRegistryPluginModel = ClassRegistry::isKeySet('TestRegistryPluginModel');
$this->assertFalse($TestRegistryPluginModel);
$TestRegistryPluginModel = ClassRegistry::init('RegistryPlugin.TestRegistryPluginModel');
$this->assertTrue(is_a($TestRegistryPluginModel, 'TestRegistryPluginModel'));
$this->assertEqual($TestRegistryPluginModel->tablePrefix, 'something_');
if (PHP5) {
$PluginUser = ClassRegistry::init(array('class' => 'RegistryPlugin.RegisterUser', 'alias' => 'RegistryPluginUser', 'table' => false));
} else {
$PluginUser =& ClassRegistry::init(array('class' => 'RegistryPlugin.RegisterUser', 'alias' => 'RegistryPluginUser', 'table' => false));
}
$this->assertTrue(is_a($PluginUser, 'RegistryPluginAppModel'));
if (PHP5) {
$PluginUserCopy = ClassRegistry::getObject('RegistryPluginUser');
} else {
$PluginUserCopy =& ClassRegistry::getObject('RegistryPluginUser');
}
$this->assertTrue(is_a($PluginUserCopy, 'RegistryPluginAppModel'));
$this->assertIdentical($PluginUser, $PluginUserCopy);
} | testPluginAppModel method
@access public
@return void | testPluginAppModel | php | Datawalke/Coordino | cake/tests/cases/libs/class_registry.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/class_registry.test.php | MIT |
function skip() {
$this->skipIf(!extension_loaded('xdebug'), '%s XDebug not installed');
} | Skip if XDebug not installed
@access public | skip | php | Datawalke/Coordino | cake/tests/cases/libs/code_coverage_manager.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/code_coverage_manager.test.php | MIT |
function startCase() {
$this->_get = $_GET;
} | startTest Method
Store reference of $_GET to restore later.
@return void | startCase | php | Datawalke/Coordino | cake/tests/cases/libs/code_coverage_manager.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/code_coverage_manager.test.php | MIT |
function endCase() {
$_GET = $this->_get;
} | End Case - restore GET vars.
@return void | endCase | php | Datawalke/Coordino | cake/tests/cases/libs/code_coverage_manager.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/code_coverage_manager.test.php | MIT |
function testNoTestCaseSupplied() {
if ($this->skipIf(PHP_SAPI == 'cli', 'Is cli, cannot run this test %s')) {
return;
}
$reporter =& new CakeHtmlReporter(null, array('group' => false, 'app' => false, 'plugin' => false));
CodeCoverageManager::init(substr(md5(microtime()), 0, 5), $reporter);
CodeCoverageManager::report(false);
$this->assertError();
CodeCoverageManager::init('tests' . DS . 'lib' . DS . basename(__FILE__), $reporter);
CodeCoverageManager::report(false);
$this->assertError();
} | testNoTestCaseSupplied method
@access public
@return void | testNoTestCaseSupplied | php | Datawalke/Coordino | cake/tests/cases/libs/code_coverage_manager.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/code_coverage_manager.test.php | MIT |
function testNoTestCaseSuppliedNoErrors() {
if ($this->skipIf(PHP_SAPI == 'cli', 'Is cli, cannot run this test %s')) {
return;
}
$reporter =& new CakeHtmlReporter(null, array('group' => false, 'app' => false, 'plugin' => false));
$path = LIBS;
if (strpos(LIBS, ROOT) === false) {
$path = ROOT.DS.LIBS;
}
App::import('Core', 'Folder');
$folder = new Folder();
$folder->cd($path);
$contents = $folder->read();
$contents[1] = array_filter($contents[1], array(&$this, '_basenameFilter'));
foreach ($contents[1] as $file) {
CodeCoverageManager::init('libs' . DS . $file, $reporter);
CodeCoverageManager::report(false);
$this->assertNoErrors('libs' . DS . $file);
}
} | Test that test cases don't cause errors
@return void | testNoTestCaseSuppliedNoErrors | php | Datawalke/Coordino | cake/tests/cases/libs/code_coverage_manager.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/code_coverage_manager.test.php | MIT |
function _basenameFilter($var) {
return ($var != basename(__FILE__));
} | Remove file names that don't share a basename with the current file.
@return void | _basenameFilter | php | Datawalke/Coordino | cake/tests/cases/libs/code_coverage_manager.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/code_coverage_manager.test.php | MIT |
function testGetTestObjectFileNameFromTestCaseFile() {
$manager =& CodeCoverageManager::getInstance();
$manager->reporter = new CakeHtmlReporter();
$expected = $manager->__testObjectFileFromCaseFile('models/some_file.test.php', true);
$this->assertIdentical(APP.'models'.DS.'some_file.php', $expected);
$expected = $manager->__testObjectFileFromCaseFile('models/datasources/some_file.test.php', true);
$this->assertIdentical(APP.'models'.DS.'datasources'.DS.'some_file.php', $expected);
$expected = $manager->__testObjectFileFromCaseFile('controllers/some_file.test.php', true);
$this->assertIdentical(APP.'controllers'.DS.'some_file.php', $expected);
$expected = $manager->__testObjectFileFromCaseFile('views/some_file.test.php', true);
$this->assertIdentical(APP.'views'.DS.'some_file.php', $expected);
$expected = $manager->__testObjectFileFromCaseFile('behaviors/some_file.test.php', true);
$this->assertIdentical(APP.'models'.DS.'behaviors'.DS.'some_file.php', $expected);
$expected = $manager->__testObjectFileFromCaseFile('components/some_file.test.php', true);
$this->assertIdentical(APP.'controllers'.DS.'components'.DS.'some_file.php', $expected);
$expected = $manager->__testObjectFileFromCaseFile('helpers/some_file.test.php', true);
$this->assertIdentical(APP.'views'.DS.'helpers'.DS.'some_file.php', $expected);
$manager->pluginTest = 'bugs';
$expected = $manager->__testObjectFileFromCaseFile('models/some_file.test.php', false);
$this->assertIdentical(APP.'plugins'.DS.'bugs'.DS.'models'.DS.'some_file.php', $expected);
$manager->pluginTest = false;
$manager->reporter = new CakeCliReporter;
$expected = $manager->__testObjectFileFromCaseFile('libs/set.test.php', false);
$this->assertIdentical(ROOT.DS.'cake'.DS.'libs'.DS.'set.php', $expected);
} | testGetTestObjectFileNameFromTestCaseFile method
@access public
@return void | testGetTestObjectFileNameFromTestCaseFile | php | Datawalke/Coordino | cake/tests/cases/libs/code_coverage_manager.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/code_coverage_manager.test.php | MIT |
function testOfHtmlDiffReport() {
$manager =& CodeCoverageManager::getInstance();
$code = <<<PHP
/**
* Set class
*
* @package cake
* @subpackage cake.tests.cases.libs
*/
class Set extends Object {
/**
* Value of the Set object.
*
* @var array
* @access public
*/
var \$value = array();
/**
* Constructor. Defaults to an empty array.
*
* @access public
*/
function __construct() {
if (func_num_args() == 1 && is_array(func_get_arg(0))) {
\$this->value = func_get_arg(0);
} else {
\$this->value = func_get_args();
}
}
/**
* Returns the contents of the Set object
*
* @return array
* @access public
*/
function &get() {
return \$this->value;
}
/**
* This function can be thought of as a hybrid between PHP's array_merge and array_merge_recursive. The difference
* to the two is that if an array key contains another array then the function behaves recursive (unlike array_merge)
* but does not do if for keys containing strings (unlike array_merge_recursive). See the unit test for more information.
*
* Note: This function will work with an unlimited amount of arguments and typecasts non-array parameters into arrays.
*
* @param array \$arr1 Array to be merged
* @param array \$arr2 Array to merge with
* @return array Merged array
* @access public
*/
function merge(\$arr1, \$arr2 = null) {
\$args = func_get_args();
if (isset(\$this) && is_a(\$this, 'set')) {
\$backtrace = debug_backtrace();
\$previousCall = strtolower(\$backtrace[1]['class'].'::'.\$backtrace[1]['function']);
if (\$previousCall != 'set::merge') {
\$r =& \$this->value;
array_unshift(\$args, null);
}
}
if (!isset(\$r)) {
\$r = (array)current(\$args);
}
while ((\$arg = next(\$args)) !== false) {
if (is_a(\$arg, 'set')) {
\$arg = \$arg->get();
}
foreach ((array)\$arg as \$key => \$val) {
if (is_array(\$val) && isset(\$r[\$key]) && is_array(\$r[\$key])) {
\$r[\$key] = Set::merge(\$r[\$key], \$val);
} elseif (is_int(\$key)) {
} else {
\$r[\$key] = \$val;
}
}
}
return \$r;
}
PHP;
$testObjectFile = explode("\n", $code);
$coverageData = array(
0 => 1,
1 => 1,
2 => -2,
3 => -2,
4 => -2,
5 => -2,
6 => -2,
7 => -2,
8 => -1,
9 => -2,
10 => -2,
11 => -2,
12 => -2,
13 => -2,
14 => 1,
15 => 1,
16 => -1,
17 => 1,
18 => 1,
19 => -1,
20 => 1,
21 => -2,
22 => -2,
23 => -2,
24 => -2,
25 => -2,
26 => -2,
27 => 1,
28 => -1,
29 => 1,
30 => 1,
31 => -2,
32 => -2,
33 => -2,
34 => -2,
35 => -2,
36 => -2,
37 => -2,
38 => -2,
39 => -2,
40 => -2,
41 => -2,
42 => -2,
43 => -1,
44 => -2,
45 => -2,
46 => -2,
47 => -2,
48 => 1,
49 => 1,
50 => -1,
51 => 1,
52 => 1,
53 => -2,
54 => -2,
55 => 1,
56 => 1,
57 => 1,
58 => 1,
59 => -1,
60 => 1,
61 => 1,
62 => -2,
63 => -2,
64 => 1,
65 => -2,
66 => 1,
67 => -1,
68 => -2,
69 => -1,
70 => -1,
71 => 1,
72 => -2,
);
$expected = array(
0 => 'ignored',
1 => 'ignored',
2 => 'ignored',
3 => 'ignored',
4 => 'ignored',
5 => 'ignored show start realstart',
6 => 'ignored show',
7 => 'ignored show',
8 => 'uncovered show',
9 => 'ignored show',
10 => 'ignored show',
11 => 'ignored show end',
12 => 'ignored',
13 => 'ignored show start',
14 => 'covered show',
15 => 'covered show',
16 => 'uncovered show',
17 => 'covered show show',
18 => 'covered show show',
19 => 'uncovered show',
20 => 'covered show',
21 => 'ignored show',
22 => 'ignored show end',
23 => 'ignored',
24 => 'ignored',
25 => 'ignored show start',
26 => 'ignored show',
27 => 'covered show',
28 => 'uncovered show',
29 => 'covered show',
30 => 'covered show',
31 => 'ignored show end',
32 => 'ignored',
33 => 'ignored',
34 => 'ignored',
35 => 'ignored',
36 => 'ignored',
37 => 'ignored',
38 => 'ignored',
39 => 'ignored',
40 => 'ignored show start',
41 => 'ignored show',
42 => 'ignored show',
43 => 'uncovered show',
41 => 'ignored show',
42 => 'ignored show',
43 => 'uncovered show',
44 => 'ignored show',
45 => 'ignored show',
46 => 'ignored show',
47 => 'ignored show',
48 => 'covered show',
49 => 'covered show',
50 => 'uncovered show',
51 => 'covered show',
52 => 'covered show',
53 => 'ignored show end',
54 => 'ignored',
55 => 'covered',
56 => 'covered show start',
57 => 'covered show',
58 => 'covered show',
59 => 'uncovered show',
60 => 'covered show',
61 => 'covered show',
62 => 'ignored show end',
63 => 'ignored',
64 => 'covered show start',
65 => 'ignored show',
66 => 'covered show show',
67 => 'uncovered show',
68 => 'ignored show',
69 => 'uncovered show',
70 => 'uncovered show',
71 => 'covered show',
72 => 'ignored show',
73 => 'ignored show end end',
);
$execCodeLines = range(0, 72);
$result = explode("</div>", $report = $manager->reportCaseHtmlDiff($testObjectFile, $coverageData, $execCodeLines, 3));
foreach ($result as $line) {
preg_match('/<span class="line-num">(.*?)<\/span>/', $line, $matches);
if (!isset($matches[1])) {
continue;
}
$num = $matches[1];
$class = $expected[$num];
$pattern = '/<div class="code-line '.$class.'">/';
$this->assertPattern($pattern, $line, $num.': '.$line." fails");
}
} | testOfHtmlDiffReport method
@access public
@return void | testOfHtmlDiffReport | php | Datawalke/Coordino | cake/tests/cases/libs/code_coverage_manager.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/code_coverage_manager.test.php | MIT |
function testArrayStrrpos() {
$manager =& CodeCoverageManager::getInstance();
$a = array(
'apples',
'bananas',
'oranges'
);
$this->assertEqual(1, $manager->__array_strpos($a, 'ba', true));
$this->assertEqual(2, $manager->__array_strpos($a, 'range', true));
$this->assertEqual(0, $manager->__array_strpos($a, 'pp', true));
$this->assertFalse($manager->__array_strpos('', 'ba', true));
$this->assertFalse($manager->__array_strpos(false, 'ba', true));
$this->assertFalse($manager->__array_strpos(array(), 'ba', true));
$a = array(
'rang',
'orange',
'oranges'
);
$this->assertEqual(0, $manager->__array_strpos($a, 'rang'));
$this->assertEqual(2, $manager->__array_strpos($a, 'rang', true));
$this->assertEqual(1, $manager->__array_strpos($a, 'orange', false));
$this->assertEqual(1, $manager->__array_strpos($a, 'orange'));
$this->assertEqual(2, $manager->__array_strpos($a, 'orange', true));
} | testArrayStrrpos method
@access public
@return void | testArrayStrrpos | php | Datawalke/Coordino | cake/tests/cases/libs/code_coverage_manager.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/code_coverage_manager.test.php | MIT |
function testGetExecutableLines() {
$manager =& CodeCoverageManager::getInstance();
$code = <<<HTML
\$manager =& CodeCoverageManager::getInstance();
HTML;
$result = $manager->__getExecutableLines($code);
foreach ($result as $line) {
$this->assertNotIdentical($line, '');
}
$code = <<<HTML
{
}
<?php?>
?>
<?php
}
{{}}
(())
@codeCoverageIgnoreStart
some
more
code
here
@codeCoverageIgnoreEnd
HTML;
$result = $manager->__getExecutableLines($code);
foreach ($result as $line) {
$this->assertIdentical(trim($line), '');
}
} | testGetExecutableLines method
@access public
@return void | testGetExecutableLines | php | Datawalke/Coordino | cake/tests/cases/libs/code_coverage_manager.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/code_coverage_manager.test.php | MIT |
function testCalculateCodeCoverage() {
$manager =& CodeCoverageManager::getInstance();
$data = array(
'25' => array(100, 25),
'50' => array(100, 50),
'0' => array(0, 0),
'0' => array(100, 0),
'100' => array(100, 100),
);
foreach ($data as $coverage => $lines) {
$this->assertEqual($coverage, $manager->__calcCoverage($lines[0], $lines[1]));
}
$manager->__calcCoverage(100, 1000);
$this->assertError();
} | testCalculateCodeCoverage method
@access public
@return void | testCalculateCodeCoverage | php | Datawalke/Coordino | cake/tests/cases/libs/code_coverage_manager.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/code_coverage_manager.test.php | MIT |
function setUp() {
$this->_cacheDisable = Configure::read('Cache.disable');
$this->_debug = Configure::read('debug');
Configure::write('Cache.disable', true);
} | setUp method
@access public
@return void | setUp | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function tearDown() {
if (file_exists(TMP . 'cache' . DS . 'persistent' . DS . 'cake_core_core_paths')) {
unlink(TMP . 'cache' . DS . 'persistent' . DS . 'cake_core_core_paths');
}
if (file_exists(TMP . 'cache' . DS . 'persistent' . DS . 'cake_core_dir_map')) {
unlink(TMP . 'cache' . DS . 'persistent' . DS . 'cake_core_dir_map');
}
if (file_exists(TMP . 'cache' . DS . 'persistent' . DS . 'cake_core_file_map')) {
unlink(TMP . 'cache' . DS . 'persistent' . DS . 'cake_core_file_map');
}
if (file_exists(TMP . 'cache' . DS . 'persistent' . DS . 'cake_core_object_map')) {
unlink(TMP . 'cache' . DS . 'persistent' . DS . 'cake_core_object_map');
}
if (file_exists(TMP . 'cache' . DS . 'persistent' . DS . 'test.config.php')) {
unlink(TMP . 'cache' . DS . 'persistent' . DS . 'test.config.php');
}
if (file_exists(TMP . 'cache' . DS . 'persistent' . DS . 'test.php')) {
unlink(TMP . 'cache' . DS . 'persistent' . DS . 'test.php');
}
Configure::write('debug', $this->_debug);
Configure::write('Cache.disable', $this->_cacheDisable);
} | tearDown method
@access public
@return void | tearDown | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testRead() {
$expected = 'ok';
Configure::write('level1.level2.level3_1', $expected);
Configure::write('level1.level2.level3_2', 'something_else');
$result = Configure::read('level1.level2.level3_1');
$this->assertEqual($expected, $result);
$result = Configure::read('level1.level2.level3_2');
$this->assertEqual($result, 'something_else');
$result = Configure::read('debug');
$this->assertTrue($result >= 0);
} | testRead method
@access public
@return void | testRead | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testWrite() {
$writeResult = Configure::write('SomeName.someKey', 'myvalue');
$this->assertTrue($writeResult);
$result = Configure::read('SomeName.someKey');
$this->assertEqual($result, 'myvalue');
$writeResult = Configure::write('SomeName.someKey', null);
$this->assertTrue($writeResult);
$result = Configure::read('SomeName.someKey');
$this->assertEqual($result, null);
$expected = array('One' => array('Two' => array('Three' => array('Four' => array('Five' => 'cool')))));
$writeResult = Configure::write('Key', $expected);
$this->assertTrue($writeResult);
$result = Configure::read('Key');
$this->assertEqual($expected, $result);
$result = Configure::read('Key.One');
$this->assertEqual($expected['One'], $result);
$result = Configure::read('Key.One.Two');
$this->assertEqual($expected['One']['Two'], $result);
$result = Configure::read('Key.One.Two.Three.Four.Five');
$this->assertEqual('cool', $result);
} | testWrite method
@access public
@return void | testWrite | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testInteractionOfDebugAndLog() {
Configure::write('log', false);
Configure::write('debug', 0);
$this->assertEqual(ini_get('error_reporting'), 0);
$this->assertEqual(ini_get('display_errors'), 0);
Configure::write('log', E_WARNING);
Configure::write('debug', 0);
$this->assertEqual(ini_get('error_reporting'), E_WARNING);
$this->assertEqual(ini_get('display_errors'), 0);
Configure::write('debug', 2);
$this->assertEqual(ini_get('error_reporting'), E_ALL & ~E_DEPRECATED & ~E_STRICT);
$this->assertEqual(ini_get('display_errors'), 1);
Configure::write('debug', 0);
Configure::write('log', false);
$this->assertEqual(ini_get('error_reporting'), 0);
$this->assertEqual(ini_get('display_errors'), 0);
} | test that log and debug configure values interact well.
@return void | testInteractionOfDebugAndLog | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testDelete() {
Configure::write('SomeName.someKey', 'myvalue');
$result = Configure::read('SomeName.someKey');
$this->assertEqual($result, 'myvalue');
Configure::delete('SomeName.someKey');
$result = Configure::read('SomeName.someKey');
$this->assertTrue($result === null);
Configure::write('SomeName', array('someKey' => 'myvalue', 'otherKey' => 'otherValue'));
$result = Configure::read('SomeName.someKey');
$this->assertEqual($result, 'myvalue');
$result = Configure::read('SomeName.otherKey');
$this->assertEqual($result, 'otherValue');
Configure::delete('SomeName');
$result = Configure::read('SomeName.someKey');
$this->assertTrue($result === null);
$result = Configure::read('SomeName.otherKey');
$this->assertTrue($result === null);
} | testDelete method
@access public
@return void | testDelete | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testLoad() {
$result = Configure::load('non_existing_configuration_file');
$this->assertFalse($result);
$result = Configure::load('config');
$this->assertTrue($result);
$result = Configure::load('../../index');
$this->assertFalse($result);
} | testLoad method
@access public
@return void | testLoad | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testLoadPlugin() {
App::build(array('plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)), true);
$result = Configure::load('test_plugin.load');
$this->assertTrue($result);
$expected = '/test_app/plugins/test_plugin/config/load.php';
$config = Configure::read('plugin_load');
$this->assertEqual($config, $expected);
$result = Configure::load('test_plugin.more.load');
$this->assertTrue($result);
$expected = '/test_app/plugins/test_plugin/config/more.load.php';
$config = Configure::read('plugin_more_load');
$this->assertEqual($config, $expected);
} | testLoad method
@access public
@return void | testLoadPlugin | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testStoreAndLoad() {
Configure::write('Cache.disable', false);
$expected = array('data' => 'value with backslash \, \'singlequote\' and "doublequotes"');
Configure::store('SomeExample', 'test', $expected);
Configure::load('test');
$config = Configure::read('SomeExample');
$this->assertEqual($config, $expected);
$expected = array(
'data' => array('first' => 'value with backslash \, \'singlequote\' and "doublequotes"', 'second' => 'value2'),
'data2' => 'value'
);
Configure::store('AnotherExample', 'test_config', $expected);
Configure::load('test_config');
$config = Configure::read('AnotherExample');
$this->assertEqual($config, $expected);
} | testStore method
@access public
@return void | testStoreAndLoad | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testVersion() {
$result = Configure::version();
$this->assertTrue(version_compare($result, '1.2', '>='));
} | testVersion method
@access public
@return void | testVersion | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testBuild() {
$old = App::path('models');
$expected = array(
APP . 'models' . DS,
APP,
ROOT . DS . LIBS . 'model' . DS
);
$this->assertEqual($expected, $old);
App::build(array('models' => array('/path/to/models/')));
$new = App::path('models');
$expected = array(
'/path/to/models/',
APP . 'models' . DS,
APP,
ROOT . DS . LIBS . 'model' . DS
);
$this->assertEqual($expected, $new);
App::build(); //reset defaults
$defaults = App::path('models');
$this->assertEqual($old, $defaults);
} | testBuild method
@access public
@return void | testBuild | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testBuildWithReset() {
$old = App::path('models');
$expected = array(
APP . 'models' . DS,
APP,
ROOT . DS . LIBS . 'model' . DS
);
$this->assertEqual($expected, $old);
App::build(array('models' => array('/path/to/models/')), true);
$new = App::path('models');
$expected = array(
'/path/to/models/'
);
$this->assertEqual($expected, $new);
App::build(); //reset defaults
$defaults = App::path('models');
$this->assertEqual($old, $defaults);
} | testBuildWithReset method
@access public
@return void | testBuildWithReset | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testCore() {
$model = App::core('models');
$this->assertEqual(array(ROOT . DS . LIBS . 'model' . DS), $model);
$view = App::core('views');
$this->assertEqual(array(ROOT . DS . LIBS . 'view' . DS), $view);
$controller = App::core('controllers');
$this->assertEqual(array(ROOT . DS . LIBS . 'controller' . DS), $controller);
} | testCore method
@access public
@return void | testCore | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testListObjects() {
$result = App::objects('class', TEST_CAKE_CORE_INCLUDE_PATH . 'libs');
$this->assertTrue(in_array('Xml', $result));
$this->assertTrue(in_array('Cache', $result));
$this->assertTrue(in_array('HttpSocket', $result));
$result = App::objects('behavior');
$this->assertTrue(in_array('Tree', $result));
$result = App::objects('controller');
$this->assertTrue(in_array('Pages', $result));
$result = App::objects('component');
$this->assertTrue(in_array('Auth', $result));
$result = App::objects('view');
$this->assertTrue(in_array('Media', $result));
$result = App::objects('helper');
$this->assertTrue(in_array('Html', $result));
$result = App::objects('model');
$notExpected = array('AppModel', 'ModelBehavior', 'ConnectionManager', 'DbAcl', 'Model', 'CakeSchema');
foreach ($notExpected as $class) {
$this->assertFalse(in_array($class, $result));
}
$result = App::objects('file');
$this->assertFalse($result);
$result = App::objects('file', 'non_existing_configure');
$expected = array();
$this->assertEqual($result, $expected);
$result = App::objects('NonExistingType');
$this->assertFalse($result);
App::build(array(
'plugins' => array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS
)
));
$result = App::objects('plugin', null, false);
$this->assertTrue(in_array('Cache', $result));
$this->assertTrue(in_array('Log', $result));
App::build();
} | testListObjects method
@access public
@return void | testListObjects | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testPluginPath() {
App::build(array(
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
$path = App::pluginPath('test_plugin');
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS;
$this->assertEqual($path, $expected);
$path = App::pluginPath('TestPlugin');
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS;
$this->assertEqual($path, $expected);
$path = App::pluginPath('TestPluginTwo');
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin_two' . DS;
$this->assertEqual($path, $expected);
App::build();
} | test that pluginPath can find paths for plugins.
@return void | testPluginPath | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testThemePath() {
App::build(array(
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS)
));
$path = App::themePath('test_theme');
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS;
$this->assertEqual($path, $expected);
$path = App::themePath('TestTheme');
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS;
$this->assertEqual($path, $expected);
App::build();
} | test that pluginPath can find paths for plugins.
@return void | testThemePath | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testClassLoading() {
$file = App::import();
$this->assertTrue($file);
$file = App::import('Model', 'Model', false);
$this->assertTrue($file);
$this->assertTrue(class_exists('Model'));
$file = App::import('Controller', 'Controller', false);
$this->assertTrue($file);
$this->assertTrue(class_exists('Controller'));
$file = App::import('Component', 'Component', false);
$this->assertTrue($file);
$this->assertTrue(class_exists('Component'));
$file = App::import('Shell', 'Shell', false);
$this->assertTrue($file);
$this->assertTrue(class_exists('Shell'));
$file = App::import('Model', 'SomeRandomModelThatDoesNotExist', false);
$this->assertFalse($file);
$file = App::import('Model', 'AppModel', false);
$this->assertTrue($file);
$this->assertTrue(class_exists('AppModel'));
$file = App::import('WrongType', null, true, array(), '');
$this->assertTrue($file);
$file = App::import('Model', 'NonExistingPlugin.NonExistingModel', false);
$this->assertFalse($file);
$file = App::import('Core', 'NonExistingPlugin.NonExistingModel', false);
$this->assertFalse($file);
$file = App::import('Model', array('NonExistingPlugin.NonExistingModel'), false);
$this->assertFalse($file);
$file = App::import('Core', array('NonExistingPlugin.NonExistingModel'), false);
$this->assertFalse($file);
$file = App::import('Core', array('NonExistingPlugin.NonExistingModel.AnotherChild'), false);
$this->assertFalse($file);
if (!class_exists('AppController')) {
$classes = array_flip(get_declared_classes());
if (PHP5) {
$this->assertFalse(isset($classes['PagesController']));
$this->assertFalse(isset($classes['AppController']));
} else {
$this->assertFalse(isset($classes['pagescontroller']));
$this->assertFalse(isset($classes['appcontroller']));
}
$file = App::import('Controller', 'Pages');
$this->assertTrue($file);
$this->assertTrue(class_exists('PagesController'));
$classes = array_flip(get_declared_classes());
if (PHP5) {
$this->assertTrue(isset($classes['PagesController']));
$this->assertTrue(isset($classes['AppController']));
} else {
$this->assertTrue(isset($classes['pagescontroller']));
$this->assertTrue(isset($classes['appcontroller']));
}
$file = App::import('Behavior', 'Containable');
$this->assertTrue($file);
$this->assertTrue(class_exists('ContainableBehavior'));
$file = App::import('Component', 'RequestHandler');
$this->assertTrue($file);
$this->assertTrue(class_exists('RequestHandlerComponent'));
$file = App::import('Helper', 'Form');
$this->assertTrue($file);
$this->assertTrue(class_exists('FormHelper'));
$file = App::import('Model', 'NonExistingModel');
$this->assertFalse($file);
$file = App::import('Datasource', 'DboSource');
$this->assertTrue($file);
$this->assertTrue(class_exists('DboSource'));
}
App::build();
} | testClassLoading method
@access public
@return void | testClassLoading | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testPluginImporting() {
App::build(array(
'libs' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
$result = App::import('Controller', 'TestPlugin.Tests');
$this->assertTrue($result);
$this->assertTrue(class_exists('TestPluginAppController'));
$this->assertTrue(class_exists('TestsController'));
$result = App::import('Lib', 'TestPlugin.TestPluginLibrary');
$this->assertTrue($result);
$this->assertTrue(class_exists('TestPluginLibrary'));
$result = App::import('Lib', 'Library');
$this->assertTrue($result);
$this->assertTrue(class_exists('Library'));
$result = App::import('Helper', 'TestPlugin.OtherHelper');
$this->assertTrue($result);
$this->assertTrue(class_exists('OtherHelperHelper'));
$result = App::import('Helper', 'TestPlugin.TestPluginApp');
$this->assertTrue($result);
$this->assertTrue(class_exists('TestPluginAppHelper'));
$result = App::import('Datasource', 'TestPlugin.TestSource');
$this->assertTrue($result);
$this->assertTrue(class_exists('TestSource'));
App::build();
} | test import() with plugins
@return void | testPluginImporting | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testImportingHelpersFromAlternatePaths() {
App::build();
$this->assertFalse(class_exists('BananaHelper'), 'BananaHelper exists, cannot test importing it.');
App::import('Helper', 'Banana');
$this->assertFalse(class_exists('BananaHelper'), 'BananaHelper was not found because the path does not exist.');
App::build(array(
'helpers' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'helpers' . DS)
));
App::build(array('vendors' => array(TEST_CAKE_CORE_INCLUDE_PATH)));
$this->assertFalse(class_exists('BananaHelper'), 'BananaHelper exists, cannot test importing it.');
App::import('Helper', 'Banana');
$this->assertTrue(class_exists('BananaHelper'), 'BananaHelper was not loaded.');
App::build();
} | test that building helper paths actually works.
@return void
@link http://cakephp.lighthouseapp.com/projects/42648/tickets/410 | testImportingHelpersFromAlternatePaths | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testFileLoading () {
$file = App::import('File', 'RealFile', false, array(), TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php');
$this->assertTrue($file);
$file = App::import('File', 'NoFile', false, array(), TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'cake' . DS . 'config.php');
$this->assertFalse($file);
} | testFileLoading method
@access public
@return void | testFileLoading | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testFileLoadingWithArray() {
$type = array('type' => 'File', 'name' => 'SomeName', 'parent' => false,
'file' => TEST_CAKE_CORE_INCLUDE_PATH . DS . 'config' . DS . 'config.php');
$file = App::import($type);
$this->assertTrue($file);
$type = array('type' => 'File', 'name' => 'NoFile', 'parent' => false,
'file' => TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'cake' . DS . 'config.php');
$file = App::import($type);
$this->assertFalse($file);
} | testFileLoadingWithArray method
@access public
@return void | testFileLoadingWithArray | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testFileLoadingReturnValue () {
$file = App::import('File', 'Name', false, array(), TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php', true);
$this->assertTrue($file);
$this->assertTrue(isset($file['Cake.version']));
$type = array('type' => 'File', 'name' => 'OtherName', 'parent' => false,
'file' => TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php', 'return' => true);
$file = App::import($type);
$this->assertTrue($file);
$this->assertTrue(isset($file['Cake.version']));
} | testFileLoadingReturnValue method
@access public
@return void | testFileLoadingReturnValue | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testLoadingWithSearch () {
$file = App::import('File', 'NewName', false, array(TEST_CAKE_CORE_INCLUDE_PATH ), 'config.php');
$this->assertTrue($file);
$file = App::import('File', 'AnotherNewName', false, array(LIBS), 'config.php');
$this->assertFalse($file);
} | testLoadingWithSearch method
@access public
@return void | testLoadingWithSearch | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testLoadingWithSearchArray () {
$type = array('type' => 'File', 'name' => 'RandomName', 'parent' => false, 'file' => 'config.php', 'search' => array(TEST_CAKE_CORE_INCLUDE_PATH ));
$file = App::import($type);
$this->assertTrue($file);
$type = array('type' => 'File', 'name' => 'AnotherRandomName', 'parent' => false, 'file' => 'config.php', 'search' => array(LIBS));
$file = App::import($type);
$this->assertFalse($file);
} | testLoadingWithSearchArray method
@access public
@return void | testLoadingWithSearchArray | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function testMultipleLoading() {
$toLoad = array('I18n', 'CakeSocket');
$classes = array_flip(get_declared_classes());
$this->assertFalse(isset($classes['i18n']));
$this->assertFalse(isset($classes['CakeSocket']));
$load = App::import($toLoad);
$this->assertTrue($load);
$classes = array_flip(get_declared_classes());
if (PHP5) {
$this->assertTrue(isset($classes['I18n']));
} else {
$this->assertTrue(isset($classes['i18n']));
}
$load = App::import(array('I18n', 'SomeNotFoundClass', 'CakeSocket'));
$this->assertFalse($load);
$load = App::import($toLoad);
$this->assertTrue($load);
} | testMultipleLoading method
@access public
@return void | testMultipleLoading | php | Datawalke/Coordino | cake/tests/cases/libs/configure.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/configure.test.php | MIT |
function setUp() {
Configure::write('log', false);
if (!defined('SIMPLETESTVENDORPATH')) {
if (file_exists(APP . DS . 'vendors' . DS . 'simpletest' . DS . 'reporter.php')) {
define('SIMPLETESTVENDORPATH', 'APP' . DS . 'vendors');
} else {
define('SIMPLETESTVENDORPATH', 'CORE' . DS . 'vendors');
}
}
} | setUp method
@access public
@return void | setUp | php | Datawalke/Coordino | cake/tests/cases/libs/debugger.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/debugger.test.php | MIT |
function tearDown() {
Configure::write('log', true);
} | tearDown method
@access public
@return void | tearDown | php | Datawalke/Coordino | cake/tests/cases/libs/debugger.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/debugger.test.php | MIT |
function testDocRef() {
ini_set('docref_root', '');
$this->assertEqual(ini_get('docref_root'), '');
$debugger = new Debugger();
$this->assertEqual(ini_get('docref_root'), 'http://php.net/');
} | testDocRef method
@access public
@return void | testDocRef | php | Datawalke/Coordino | cake/tests/cases/libs/debugger.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/debugger.test.php | MIT |
function testExcerpt() {
$result = Debugger::excerpt(__FILE__, __LINE__, 2);
$this->assertTrue(is_array($result));
$this->assertEqual(count($result), 5);
$this->assertPattern('/function(.+)testExcerpt/', $result[1]);
$result = Debugger::excerpt(__FILE__, 2, 2);
$this->assertTrue(is_array($result));
$this->assertEqual(count($result), 4);
$expected = '<code><span style="color: #000000"><?php';
$expected .= '</span></code>';
$this->assertEqual($result[0], $expected);
$return = Debugger::excerpt('[internal]', 2, 2);
$this->assertTrue(empty($return));
} | test Excerpt writing
@access public
@return void | testExcerpt | php | Datawalke/Coordino | cake/tests/cases/libs/debugger.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/debugger.test.php | MIT |
function testOutput() {
Debugger::invoke(Debugger::getInstance());
$result = Debugger::output(false);
$this->assertEqual($result, '');
$out .= '';
$result = Debugger::output(true);
$this->assertEqual($result[0]['error'], 'Notice');
$this->assertPattern('/Undefined variable\:\s+out/', $result[0]['description']);
$this->assertPattern('/DebuggerTest::testOutput/i', $result[0]['trace']);
$this->assertPattern('/SimpleInvoker::invoke/i', $result[0]['trace']);
ob_start();
Debugger::output('txt');
$other .= '';
$result = ob_get_clean();
$this->assertPattern('/Undefined variable:\s+other/', $result);
$this->assertPattern('/Context:/', $result);
$this->assertPattern('/DebuggerTest::testOutput/i', $result);
$this->assertPattern('/SimpleInvoker::invoke/i', $result);
ob_start();
Debugger::output('html');
$wrong .= '';
$result = ob_get_clean();
$this->assertPattern('/<pre class="cake-debug">.+<\/pre>/', $result);
$this->assertPattern('/<b>Notice<\/b>/', $result);
$this->assertPattern('/variable:\s+wrong/', $result);
ob_start();
Debugger::output('js');
$buzz .= '';
$result = explode('</a>', ob_get_clean());
$this->assertTags($result[0], array(
'pre' => array('class' => 'cake-debug'),
'a' => array(
'href' => "javascript:void(0);",
'onclick' => "document.getElementById('cakeErr4-trace').style.display = " .
"(document.getElementById('cakeErr4-trace').style.display == 'none'" .
" ? '' : 'none');"
),
'b' => array(), 'Notice', '/b', ' (8)',
));
$this->assertPattern('/Undefined variable:\s+buzz/', $result[1]);
$this->assertPattern('/<a[^>]+>Code/', $result[1]);
$this->assertPattern('/<a[^>]+>Context/', $result[2]);
set_error_handler('simpleTestErrorHandler');
} | testOutput method
@access public
@return void | testOutput | php | Datawalke/Coordino | cake/tests/cases/libs/debugger.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/debugger.test.php | MIT |
function testChangeOutputFormats() {
Debugger::invoke(Debugger::getInstance());
Debugger::output('js', array(
'traceLine' => '{:reference} - <a href="txmt://open?url=file://{:file}' .
'&line={:line}">{:path}</a>, line {:line}'
));
$result = Debugger::trace();
$this->assertPattern('/' . preg_quote('txmt://open?url=file:///', '/') . '/', $result);
Debugger::output('xml', array(
'error' => '<error><code>{:code}</code><file>{:file}</file><line>{:line}</line>' .
'{:description}</error>',
'context' => "<context>{:context}</context>",
'trace' => "<stack>{:trace}</stack>",
));
Debugger::output('xml');
ob_start();
$foo .= '';
$result = ob_get_clean();
set_error_handler('SimpleTestErrorHandler');
$data = array(
'error' => array(),
'code' => array(), '8', '/code',
'file' => array(), 'preg:/[^<]+/', '/file',
'line' => array(), '' . (intval(__LINE__) + -8), '/line',
'preg:/Undefined variable:\s+foo/',
'/error'
);
$this->assertTags($result, $data, true);
} | Tests that changes in output formats using Debugger::output() change the templates used.
@return void | testChangeOutputFormats | php | Datawalke/Coordino | cake/tests/cases/libs/debugger.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/debugger.test.php | MIT |
function testTrimPath() {
$this->assertEqual(Debugger::trimPath(APP), 'APP' . DS);
$this->assertEqual(Debugger::trimPath(CAKE_CORE_INCLUDE_PATH), 'CORE');
} | testTrimPath method
@access public
@return void | testTrimPath | php | Datawalke/Coordino | cake/tests/cases/libs/debugger.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/debugger.test.php | MIT |
function testExportVar() {
App::import('Controller');
$Controller = new Controller();
$Controller->helpers = array('Html', 'Form');
$View = new View($Controller);
$result = Debugger::exportVar($View);
$expected = 'ViewView::$base = NULL
View::$here = NULL
View::$plugin = NULL
View::$name = ""
View::$action = NULL
View::$params = array
View::$passedArgs = array
View::$data = array
View::$helpers = array
View::$viewPath = ""
View::$viewVars = array
View::$layout = "default"
View::$layoutPath = NULL
View::$autoRender = true
View::$autoLayout = true
View::$ext = ".ctp"
View::$subDir = NULL
View::$theme = NULL
View::$cacheAction = false
View::$validationErrors = array
View::$hasRendered = false
View::$loaded = array
View::$modelScope = false
View::$model = NULL
View::$association = NULL
View::$field = NULL
View::$fieldSuffix = NULL
View::$modelId = NULL
View::$uuids = array
View::$output = false
View::$__passedVars = array
View::$__scripts = array
View::$__paths = array
View::$webroot = NULL';
$result = str_replace(array("\t", "\r\n", "\n"), "", strtolower($result));
$expected = str_replace(array("\t", "\r\n", "\n"), "", strtolower($expected));
$this->assertEqual($result, $expected);
} | testExportVar method
@access public
@return void | testExportVar | php | Datawalke/Coordino | cake/tests/cases/libs/debugger.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/debugger.test.php | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.