This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir -p /usr/cross-freebsd/x86_64-pc-freebsd7/include | |
mkdir -p /usr/cross-freebsd/x86_64-pc-freebsd7/lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tar jxf binutils-2.21.tar.bz2 | |
cd binutils-2.21 | |
./configure --enable-libssp --enable-gold --enable-ld --target=x86_64-pc-freebsd7 --prefix=/usr/cross-freebsd | |
gmake | |
gmake install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace { | |
// This allow us to configure the behavior of the "global mock" | |
$mockSocketCreate = false; | |
} | |
namespace My\Nice\Namezpace { | |
// And this here, does the trick: it will override the socket_create() | |
// function in your code *just for the namespace* where you are defining it. | |
// This relies on the code above calling the socket_create function without |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
phpunit --debug --process-isolation --verbose --stop-on-incomplete --stop-on-skipped --stop-on-failure --stop-on-error --colors --coverage-html html Test_SomeClass.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace My\Nice\Namezpace; | |
class SomeClass | |
{ | |
public function doSomething() | |
{ | |
// Notice how the global function "socket_create" is called without | |
// the leading backslash (relative instead of absolute call in a | |
// namespaced environment). This will let us later mock the call |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$req = "<?xml version='1.0' encoding='UTF-8' ?>; | |
<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' | |
xmlns:xsd='http://www.w3.org/2001/XMLSchema' | |
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' | |
xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' | |
xmlns:ns1='urn:Something'> | |
<SOAP-ENV:Body> | |
<ns1:SomeMethodRequiringAnAttachment> | |
</ns1:SomeMethodRequiringAnAttachment> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Send a POST requst using cURL | |
* @param string $url to request | |
* @param array $post values to send | |
* @param array $options for cURL | |
* @return string | |
*/ | |
function curl_post($url, $post = NULL) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function send($url, $msg, $attachments = array()) | |
{ | |
$tempFile = tmpfile(); | |
if ($tempFile === false) { | |
throw new \Exception('Could not create temp file'); | |
} | |
$dime = new Net_DIME_Message($tempFile); | |
$dime->sendData($msg, 'http://schemas.xmlsoap.org/soap/envelope/'); | |
foreach ($attachments as $id => $attachment) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$file = './a.jpg'; | |
$fileContents = file_get_contents($file); | |
// This is computed so the attachment id is the md5 sum of the file in question. | |
$fileMD5 = md5($fileContents); | |
$result = send($req, array($fileMD5 => $fileContents)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$myDir = realpath(__DIR__ . '/..'); | |
// Register a cute autoloader for our own files. | |
spl_autoload_register(function($class) use ($srcDir) { | |
$file = "$srcDir/$class.php"; | |
if (file_exists($file)) { | |
require_once $file; | |
return true; | |
} | |
}); |