Skip to content

Instantly share code, notes, and snippets.

@scottjehl
scottjehl / hideaddrbar.js
Created August 31, 2011 11:42
Normalized hide address bar for iOS & Android
/*
* Normalized hide address bar for iOS & Android
* (c) Scott Jehl, scottjehl.com
* MIT License
*/
(function( win ){
var doc = win.document;
// If there's a hash, or addEventListener is undefined, stop here
if( !location.hash && win.addEventListener ){
@fabiosussetto
fabiosussetto / CakePHP Partial mock for a model
Created December 17, 2010 17:44
With SimpleTest, when creating a partial mock, the real object constructor is NOT called. This make impossible to mock model in tests, because things like Behaviors, etc. will not be initialized. I (probably) solved with this:
Mock::generatePartial('Article','MockArticle', array('testCall'));
// then inside the test case class:
public function startTest($method) {
parent::startTest($method);
$this->Article = new MockArticle($this);
$this->Article->alias = 'Article';
$reflectionMethod = new ReflectionMethod('Article', '__construct');
$reflectionMethod->invoke($this->Article);