function yay_parse(string $source, Directives $directives = null, BlueContext $blueContext = null) : string { if ($gc = gc_enabled()) { gc_disable(); } // important optimization! static $globalDirectives = null; if (null === $globalDirectives) { $globalDirectives = new ArrayObject(); } $directives = $directives ?: new Directives(); $blueContext = $blueContext ?: new BlueContext(); $cg = (object) ['ts' => TokenStream::fromSource($source), 'directives' => $directives, 'cycle' => new Cycle($source), 'globalDirectives' => $globalDirectives, 'blueContext' => $blueContext]; foreach ($cg->globalDirectives as $d) { $cg->directives->add($d); } traverse(midrule(function (TokenStream $ts) use($directives, $blueContext) { $token = $ts->current(); tail_call: if (null === $token) { return; } // skip when something looks like a new macro to be parsed if ('macro' === (string) $token) { return; } // here we do the 'magic' to match and expand userland macros $directives->apply($ts, $token, $blueContext); $token = $ts->next(); goto tail_call; }), consume(chain(token(T_STRING, 'macro')->as('declaration'), optional(repeat(rtoken('/^·\\w+$/')))->as('tags'), lookahead(token('{')), commit(chain(braces()->as('pattern'), operator('>>'), braces()->as('expansion')))->as('body'), optional(token(';'))), CONSUME_DO_TRIM)->onCommit(function (Ast $macroAst) use($cg) { $scope = Map::fromEmpty(); $tags = Map::fromValues(array_map('strval', $macroAst->{'tags'})); $pattern = new Pattern($macroAst->{'declaration'}->line(), $macroAst->{'body pattern'}, $tags, $scope); $expansion = new Expansion($macroAst->{'body expansion'}, $tags, $scope); $macro = new Macro($tags, $pattern, $expansion, $cg->cycle); $cg->directives->add($macro); // allocate the userland macro // allocate the userland macro globally if it's declared as global if ($macro->tags()->contains('·global')) { $cg->globalDirectives[] = $macro; } }))->parse($cg->ts); $expansion = (string) $cg->ts; if ($gc) { gc_enable(); } return $expansion; }
public function testBatchSendReturnCummulativeSendCount() { $transport = $this->_createTransport(); $message = $this->_createMessage(); $this->_checking(Expectations::create()->allowing($message)->getTo()->returns(array('*****@*****.**' => 'One', '*****@*****.**' => 'Two', '*****@*****.**' => 'Three'))->one($message)->setTo(array('*****@*****.**' => 'One'))->one($message)->setTo(array('*****@*****.**' => 'Two'))->one($message)->setTo(array('*****@*****.**' => 'Three'))->one($message)->setTo(array('*****@*****.**' => 'One', '*****@*****.**' => 'Two', '*****@*****.**' => 'Three'))->one($transport)->send($message, optional())->returns(1)->one($transport)->send($message, optional())->returns(0)->one($transport)->send($message, optional())->returns(1)->ignoring($transport)->ignoring($message)); $mailer = $this->_createMailer($transport); $this->assertEqual(2, $mailer->batchSend($message)); }
public function testSendReturnsCountFromTransport() { $transport = $this->_createTransport(); $message = $this->_createMessage(); $this->_checking(Expectations::create()->one($transport)->send($message, optional())->returns(57)->ignoring($transport)->ignoring($message)); $mailer = $this->_createMailer($transport); $this->assertEqual(57, $mailer->send($message)); }
public function testByteStreamAndStringCanBeAppended() { $os = $this->_createOutputStream(); $this->_checking(Expectations::create()->one($os)->read(optional())->returns('abc')->one($os)->read(optional())->returns('def')->one($os)->read(optional())->returns(false)->ignoring($os)); $is = $this->_createKeyCacheInputStream(true); $cache = $this->_createCache($is); $cache->setString($this->_key1, 'foo', 'test', Swift_KeyCache::MODE_APPEND); $cache->importFromByteStream($this->_key1, 'foo', $os, Swift_KeyCache::MODE_APPEND); $this->assertEqual('testabcdef', $cache->getString($this->_key1, 'foo')); }
private function compile(array $tokens) { $cg = (object) ['ts' => TokenStream::fromSlice($tokens), 'parsers' => []]; traverse(rtoken('/^(T_\\w+)·(\\w+)$/')->onCommit(function (Ast $result) use($cg) { $token = $result->token(); $id = $this->lookupCapture($token); $type = $this->lookupTokenType($token); $cg->parsers[] = token($type)->as($id); }), ($parser = chain(rtoken('/^·\\w+$/')->as('type'), token('('), optional(ls(either(future($parser)->as('parser'), chain(token(T_FUNCTION), parentheses()->as('args'), braces()->as('body'))->as('function'), string()->as('string'), rtoken('/^T_\\w+·\\w+$/')->as('token'), rtoken('/^T_\\w+$/')->as('constant'), rtoken('/^·this$/')->as('this'), label()->as('label'))->as('parser'), token(',')))->as('args'), commit(token(')')), optional(rtoken('/^·\\w+$/')->as('label'), null)))->onCommit(function (Ast $result) use($cg) { $cg->parsers[] = $this->compileParser($result->type, $result->args, $result->label); }), $this->layer('{', '}', braces(), $cg), $this->layer('[', ']', brackets(), $cg), $this->layer('(', ')', parentheses(), $cg), rtoken('/^···(\\w+)$/')->onCommit(function (Ast $result) use($cg) { $id = $this->lookupCapture($result->token()); $cg->parsers[] = layer()->as($id); }), token(T_STRING, '·')->onCommit(function (Ast $result) use($cg) { $offset = \count($cg->parsers); if (0 !== $this->dominance || 0 === $offset) { $this->fail(self::E_BAD_DOMINANCE, $offset, $result->token()->line()); } $this->dominance = $offset; }), rtoken('/·/')->onCommit(function (Ast $result) { $token = $result->token(); $this->fail(self::E_BAD_CAPTURE, $token, $token->line()); }), any()->onCommit(function (Ast $result) use($cg) { $cg->parsers[] = token($result->token()); }))->parse($cg->ts); // check if macro dominance '·' is last token if ($this->dominance === \count($cg->parsers)) { $this->fail(self::E_BAD_DOMINANCE, $this->dominance, $cg->ts->last()->line()); } $this->specificity = \count($cg->parsers); if ($this->specificity > 1) { if (0 === $this->dominance) { $pattern = chain(...$cg->parsers); } else { /* dominat macros are partially wrapped in commit()s and dominance is the offset used as the 'event horizon' point... once the entry point is matched, there is no way back and a parser error arises */ $prefix = array_slice($cg->parsers, 0, $this->dominance); $suffix = array_slice($cg->parsers, $this->dominance); $pattern = chain(...array_merge($prefix, array_map(commit::class, $suffix))); } } else { /* micro optimization to save one function call for every token on the subject token stream whenever the macro pattern consists of a single parser */ $pattern = $cg->parsers[0]; } return $pattern; }
public function testFirstLineCanHaveShorterLength() { $charStream = $this->_mock('Swift_CharacterStream'); $seq = $this->_sequence('byte-sequence'); $string = ''; for ($x = 0; $x < 200; ++$x) { $char = 'a'; $string .= $char; $this->_checking(Expectations::create()->one($charStream)->read(optional())->inSequence($seq)->returns($char)); } $this->_checking(Expectations::create()->atLeast(1)->of($charStream)->read(optional())->inSequence($seq)->returns(false)->one($charStream)->importString($string)->ignoring($charStream)->flushContents()); $encoder = new Swift_Encoder_Rfc2231Encoder($charStream); $encoded = $encoder->encodeString($string, 25, 75); $this->assertEqual(str_repeat('a', 50) . "\r\n" . str_repeat('a', 75) . "\r\n" . str_repeat('a', 75), $encoded, '%s: First line should be 25 bytes shorter than the others.'); }
protected function _createFileStream($path, $data, $stub = true) { $file = $this->_mock('Swift_FileStream'); $pos = $this->_mockery()->states('position')->startsAs('at start'); $this->_checking(Expectations::create()->ignoring($file)->getPath()->returns($path)->ignoring($file)->read(optional())->returns($data)->when($pos->isNot('at end'))->then($pos->is('at end'))->ignoring($file)->read(optional())->returns(false)); if ($stub) { $this->_checking(Expectations::create()->ignoring($file)); } return $file; }
public function testCanonicEncodeByteStreamGeneratesCorrectCrlf_5() { $encoder = $this->_getEncoder('7bit', true); $os = $this->_createOutputByteStream(); $is = $this->_createInputByteStream(); $collection = new Swift_StreamCollector(); $this->_checking(Expectations::create()->allowing($is)->write(any(), optional())->will($collection)->ignoring($is)->one($os)->read(optional())->returns('a')->one($os)->read(optional())->returns("\r\r")->one($os)->read(optional())->returns('b')->allowing($os)->read(optional())->returns(false)->ignoring($os)); $encoder->encodeByteStream($os, $is); $this->assertEqual("a\r\n\r\nb", $collection->content); }
} function jumpMenu() { var newIndex = document.sizejumpform.sizejump.selectedIndex; cururl = document.sizejumpform.sizejump.options[ newIndex ].value; window.location.assign( cururl ); } $(function() { $("#synctoserver").click(function() { syncPlaylist(); }); }); --> </script> <div id="box" style="width:<?php echo optional($opt["width"], $cfg["media-player"]["default-width"]) + 300; ?> px;height:480px;"> <?php include 'modules/media/player.php'; ?> <?php include 'modules/media/browser.php'; ?> <div id="mediasettings"> <label for="synctoserver"><input id="synctoserver" name="synctoserver" type="checkbox" value="1" /> Sync to Server</label> <form name="sizejumpform" action="media.php"> <select name="sizejump" onchange="jumpMenu()"> <option value="media.php?width=720&height=480" <?php if ($opt["width"] == 720) { echo "selected";
public function testFirstLineLengthCanBeDifferent() { $os = $this->_createOutputByteStream(); $is = $this->_createInputByteStream(); $collection = new Swift_StreamCollector(); $this->_checking(Expectations::create()->allowing($is)->write(any(), optional())->will($collection)->ignoring($is)->one($os)->read(optional())->returns('abcdefghijkl')->one($os)->read(optional())->returns('mnopqrstuvwx')->one($os)->read(optional())->returns('yzabc1234567')->one($os)->read(optional())->returns('890ABCDEFGHI')->one($os)->read(optional())->returns('JKLMNOPQRSTU')->one($os)->read(optional())->returns('VWXYZ1234567')->one($os)->read(optional())->returns('abcdefghijkl')->allowing($os)->read(optional())->returns(false)->ignoring($os)); $this->_encoder->encodeByteStream($os, $is, 19); $this->assertEqual("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXphYmMxMjM0NTY3ODkwQUJDR\r\n" . "EVGR0hJSktMTU5PUFFSU1RVVldYWVoxMjM0NTY3YWJjZGVmZ2hpamts", $collection->content); }
public function testRestartingTransportRestartsDeadDelegates() { $e = new Swift_TransportException('b0rken'); $context = new Mockery(); $message1 = $context->mock('Swift_Mime_Message'); $message2 = $context->mock('Swift_Mime_Message'); $t1 = $context->mock('Swift_Transport'); $t2 = $context->mock('Swift_Transport'); $con1 = $context->states('Connection')->startsAs('off'); $con2 = $context->states('Connection')->startsAs('off'); $context->checking(Expectations::create()->ignoring($message1)->ignoring($message2)->allowing($t1)->isStarted()->returns(false)->when($con1->is('off'))->allowing($t1)->isStarted()->returns(true)->when($con1->is('on'))->exactly(2)->of($t1)->start()->when($con1->isNot('on'))->then($con1->is('on'))->one($t1)->send($message1, optional())->throws($e)->when($con1->is('on'))->then($con1->is('off'))->one($t1)->send($message2, optional())->returns(10)->when($con1->is('on'))->ignoring($t1)->allowing($t2)->isStarted()->returns(false)->when($con2->is('off'))->allowing($t2)->isStarted()->returns(true)->when($con2->is('on'))->one($t2)->start()->when($con2->isNot('on'))->then($con2->is('on'))->one($t2)->send($message1, optional())->throws($e)->when($con2->is('on'))->never($t2)->send($message2, optional())->ignoring($t2)); $transport = $this->_getTransport(array($t1, $t2)); $transport->start(); $this->assertTrue($transport->isStarted()); try { $transport->send($message1); $this->fail('All transports failed so Exception should be thrown'); } catch (Exception $e) { $this->assertFalse($transport->isStarted()); } //Restart and re-try $transport->start(); $this->assertTrue($transport->isStarted()); $this->assertEqual(10, $transport->send($message2)); $context->assertIsSatisfied(); }
private function mutate(TokenStream $ts, Ast $context, Cycle $cycle, Directives $directives, BlueContext $blueContext) : TokenStream { if ($this->constant) { return $ts; } static $states, $parser; $states = $states ?? new Stack(); $parser = $parser ?? traverse(token(Token::CLOAKED), consume(chain(rtoken('/^··\\w+$/')->as('expander'), either(parentheses(), braces())->as('args')))->onCommit(function (Ast $result) use($states) { $cg = $states->current(); $expander = $result->expander; if (\count($result->args) === 0) { $cg->this->fail(self::E_EMPTY_EXPANDER_SLICE, (string) $expander, $expander->line()); } $context = Map::fromKeysAndValues(['scope' => $cg->cycle->id(), 'directives' => $cg->directives, 'blueContext' => $cg->blueContext]); $expansion = TokenStream::fromSlice($result->args); $mutation = $cg->this->mutate(clone $expansion, $cg->context, $cg->cycle, $cg->directives, $cg->blueContext); $mutation = $cg->this->lookupExpander($expander)($mutation, $context); $cg->ts->inject($mutation); }), consume(chain(rtoken('/^·\\w+|···\\w+$/')->as('label'), operator('···'), optional(parentheses()->as('delimiters')), braces()->as('expansion')))->onCommit(function (Ast $result) use($states) { $cg = $states->current(); $context = $cg->this->lookupContext($result->label, $cg->context, self::E_UNDEFINED_EXPANSION); $expansion = TokenStream::fromSlice($result->expansion); $delimiters = $result->delimiters; // normalize single context if (array_values($context) !== $context) { $context = [$context]; } foreach (array_reverse($context) as $i => $subContext) { $mutation = $cg->this->mutate(clone $expansion, (new Ast(null, $subContext))->withParent($cg->context), $cg->cycle, $cg->directives, $cg->blueContext); if ($i !== 0) { foreach ($delimiters as $d) { $mutation->push($d); } } $cg->ts->inject($mutation); } }), consume(rtoken('/^(T_\\w+·\\w+|·\\w+|···\\w+)$/')->as('label'))->onCommit(function (Ast $result) use($states) { $cg = $states->current(); $context = $cg->this->lookupContext($result->label, $cg->context, self::E_UNDEFINED_EXPANSION); if ($context instanceof Token) { $cg->ts->inject(TokenStream::fromSequence($context)); } elseif (is_array($context) && \count($context)) { $tokens = []; array_walk_recursive($context, function (Token $token) use(&$tokens) { $tokens[] = $token; }); $cg->ts->inject(TokenStream::fromSlice($tokens)); } })); $cg = (object) ['ts' => $ts, 'context' => $context, 'directives' => $directives, 'cycle' => $cycle, 'this' => $this, 'blueContext' => $blueContext]; $states->push($cg); $parser->parse($cg->ts); $states->pop(); $cg->ts->reset(); if ($this->cloaked) { traverse(consume(token(Token::CLOAKED))->onCommit(function (Ast $result) use($cg) { $cg->ts->inject(TokenStream::fromSourceWithoutOpenTag((string) $result->token())); }))->parse($cg->ts); $cg->ts->reset(); } return $cg->ts; }
private function compilePattern(int $line, array $tokens) : Parser { if (!$tokens) { $this->fail(self::E_EMPTY_PATTERN, $line); } $ts = TokenStream::fromSlice($tokens); traverse(either(consume(chain(token(T_NS_SEPARATOR), token(T_NS_SEPARATOR), parentheses()->as('cloaked')))->onCommit(function (Ast $result) use($ts) { $ts->inject(TokenStream::fromSequence(...$result->cloaked)); $ts->skip(...TokenStream::SKIPPABLE); }), rtoken('/^(T_\\w+)·(\\w+)$/')->onCommit(function (Ast $result) { $token = $result->token(); $id = $this->lookupCapture($token); $type = $this->lookupTokenType($token); $this->parsers[] = token($type)->as($id); }), ($parser = chain(rtoken('/^·\\w+$/')->as('parser_type'), token('('), optional(ls(either(future($parser)->as('parser'), string()->as('string'), rtoken('/^T_\\w+·\\w+$/')->as('token'), rtoken('/^T_\\w+$/')->as('constant'), word()->as('word')), token(',')))->as('args'), commit(token(')')), optional(rtoken('/^·\\w+$/')->as('label'))))->onCommit(function (Ast $result) { $this->parsers[] = $this->compileParser($result->array()); }), $this->layer('{', '}', braces()), $this->layer('[', ']', brackets()), $this->layer('(', ')', parentheses()), rtoken('/^···(\\w+)$/')->onCommit(function (Ast $result) { $id = $this->lookupCapture($result->token()); $this->parsers[] = layer()->as($id); }), token(T_STRING, '·')->onCommit(function (Ast $result) use($ts) { $offset = \count($this->parsers); if (0 !== $this->dominance || 0 === $offset) { $this->fail(self::E_BAD_DOMINANCE, $offset, $result->token()->line()); } $this->dominance = $offset; }), rtoken('/·/')->onCommit(function (Ast $result) { $token = $result->token(); $this->fail(self::E_BAD_CAPTURE, $token, $token->line()); }), any()->onCommit(function (Ast $result) { $this->parsers[] = token($result->token()); })))->parse($ts); // check if macro dominance '·' is last token if ($this->dominance === \count($this->parsers)) { $this->fail(self::E_BAD_DOMINANCE, $this->dominance, $ts->last()->line()); } $this->specificity = \count($this->parsers); if ($this->specificity > 1) { if (0 === $this->dominance) { $pattern = chain(...$this->parsers); } else { /* dominat macros are partially wrapped in commit()s and dominance is the offset used as the 'event horizon' point... once the entry point is matched, there is no way back and a parser error arises */ $prefix = array_slice($this->parsers, 0, $this->dominance); $suffix = array_slice($this->parsers, $this->dominance); $pattern = chain(...array_merge($prefix, array_map(commit::class, $suffix))); } } else { /* micro optimization to save one function call for every token on the subject token stream whenever the macro pattern consists of a single parser */ $pattern = $this->parsers[0]; } return $pattern; }
//lets see if we need to begin the install of phpBB2. if (isset($HTTP_POST_VARS['install_phpbb2'])) { fetch_phpbb2(); } printf("<BR><BR>Your site should now be running FishCMS. For security reasons you"); printf(" must now delete the install directory. If you are installing phpBB2 from"); printf(" FishCMS you should follow the instructions in the phpBB2 installer regarding"); printf(" deleting directories and setting permissions.<BR>"); } //===Main code================================================================ //lets write the header. install_header(); //now we will perform the install steps. if (!isset($HTTP_GET_VARS['mode'])) { pre_install(); } elseif ($HTTP_GET_VARS['mode'] == "selectdb") { selectdb(); } elseif ($HTTP_GET_VARS['mode'] == "selectauth") { selectauth(); } elseif ($HTTP_GET_VARS['mode'] == "siteconfig") { siteconfig(); } elseif ($HTTP_GET_VARS['mode'] == "optional") { optional(); } elseif ($HTTP_GET_VARS['mode'] == "finalize") { finalize(); } /* else unknown (); */ //now we write the footer. install_footer();
function testastNestedAst() { $ts = TokenStream::fromSource('<?php interface Foo { public abstract function foo(); public abstract static function bar(); function baz(); } '); $modifier = either(token(T_PUBLIC), token(T_STATIC), token(T_PRIVATE)); $modifiers = optional(either(chain($modifier, $modifier), $modifier)); $ast = chain(token(T_OPEN_TAG), chain(token(T_INTERFACE), token(T_STRING)->as('name'), token('{'), optional(repeat(chain(optional(either(repeat(either(token(T_PUBLIC)->as('public'), token(T_STATIC)->as('static'), token(T_ABSTRACT)->as('abstract'))), always(new Token(T_PUBLIC, 'public'))->as('public')))->as('is'), token(T_FUNCTION), token(T_STRING)->as('name'), token('('), token(')'), token(';')), token('}')))->as('methods'), token('}'))->as('interface'))->parse($ts); $this->assertEquals('Foo', (string) $ast->{'interface name'}); $this->assertEquals('foo', (string) $ast->{'interface methods 0 name'}); $this->assertEquals('public', (string) $ast->{'interface methods 0 is public'}); $this->assertEquals('abstract', (string) $ast->{'interface methods 0 is abstract'}); $this->assertEmpty($ast->{'interface methods 0 is static'}); $this->assertEquals('bar', (string) $ast->{'interface methods 1 name'}); $this->assertEquals('public', (string) $ast->{'interface methods 1 is public'}); $this->assertEquals('abstract', (string) $ast->{'interface methods 1 is abstract'}); $this->assertEquals('static', (string) $ast->{'interface methods 1 is static'}); $this->assertEquals('baz', (string) $ast->{'interface methods 2 name'}); $this->assertEquals('public', (string) $ast->{'interface methods 2 is public'}); $this->assertNull($ast->{'interface methods 2 is abstract'}); $this->assertNull($ast->{'interface methods 2 is static'}); }
public function testFirstLineLengthCanBeDifferent() { $input = str_repeat('a', 140); $charStream = $this->_createCharStream(); $seq = $this->_mockery()->sequence('byte-sequence'); $exps = Expectations::create(); $exps->one($charStream)->flushContents(); $exps->one($charStream)->importString($input); $output = ''; for ($i = 0; $i < 140; ++$i) { $exps->one($charStream)->readBytes(optional())->inSequence($seq)->returns(array(ord('a'))); if (53 == $i || 53 + 75 == $i) { $output .= "=\r\n"; } $output .= 'a'; } $exps->one($charStream)->readBytes(optional())->inSequence($seq)->returns(false); $this->_checking($exps); $encoder = new Swift_Encoder_QpEncoder($charStream); $this->assertEqual($output, $encoder->encodeString($input, 22), '%s: First line should start at offset 22 so can only have max length 54'); }
public function testExceptionBubblesCanBeCancelled() { $buf = $this->_getBuffer(); $dispatcher = $this->_createEventDispatcher(false); $evt = $this->_mock('Swift_Events_TransportExceptionEvent'); $smtp = $this->_getTransport($buf, $dispatcher); $this->_checking(Expectations::create()->atLeast(1)->of($buf)->readLine(any())->returns("503 I'm sleepy, go away!\r\n")->allowing($dispatcher)->createTransportExceptionEvent($smtp, optional())->returns($evt)->one($dispatcher)->dispatchEvent($evt, 'exceptionThrown')->atLeast(1)->of($evt)->bubbleCancelled()->returns(true)->ignoring($dispatcher)->ignoring($evt)); $this->_finishBuffer($buf); $smtp->start(); }
public function testSubjectHeaderIsPutBackAfterSending() { $invoker = $this->_createInvoker(); $dispatcher = $this->_createEventDispatcher(); $transport = $this->_createTransport($invoker, $dispatcher); $subject = $this->_createHeader(); $headers = $this->_createHeaders(array('Subject' => $subject)); $message = $this->_createMessage($headers); $this->_checking(Expectations::create()->one($headers)->set($subject, optional())->one($invoker)->mail(any(), any(), any(), any(), optional())->ignoring($dispatcher)->ignoring($headers)->ignoring($message)->ignoring($subject)); $transport->send($message); }
public function testChainOfCommandAlgorithmWhenNotifyingExtensions() { $buf = $this->_getBuffer(); $smtp = $this->_getTransport($buf); $ext1 = $this->_mock('Swift_Transport_EsmtpHandler'); $ext2 = $this->_mock('Swift_Transport_EsmtpHandler'); $ext3 = $this->_mock('Swift_Transport_EsmtpHandler'); $s = $this->_sequence('Initiation-sequence'); $this->_checking(Expectations::create()->one($buf)->readLine(0)->inSequence($s)->returns("220 server.com foo\r\n")->one($buf)->write(pattern('~^EHLO .*?\\r\\n$~D'))->inSequence($s)->returns(1)->one($buf)->readLine(1)->inSequence($s)->returns("250-ServerName.tld\r\n")->one($buf)->readLine(1)->inSequence($s)->returns("250-AUTH PLAIN LOGIN\r\n")->one($buf)->readLine(1)->inSequence($s)->returns("250 SIZE=123456\r\n")->never($buf)->write("FOO\r\n")->allowing($ext1)->getHandledKeyword()->returns('AUTH')->one($ext1)->onCommand($smtp, "FOO\r\n", array(250, 251), optional())->calls(array($this, 'cbStopCommand'))->allowing($ext2)->getHandledKeyword()->returns('SIZE')->never($ext2)->onCommand(any(), any(), any(), optional())->allowing($ext3)->getHandledKeyword()->returns('STARTTLS')->never($ext3)->onCommand(any(), any(), any(), optional())->ignoring($ext1)->ignoring($ext2)->ignoring($ext3)); $this->_finishBuffer($buf); $smtp->setExtensionHandlers(array($ext1, $ext2, $ext3)); $smtp->start(); $smtp->executeCommand("FOO\r\n", array(250, 251)); }
public function testFirstLineLengthCanBeDifferent() { $os = $this->_createOutputByteStream(true); $charStream = $this->_createCharacterStream(); $is = $this->_createInputByteStream(); $collection = new Swift_StreamCollector(); $this->_checking(Expectations::create()->one($charStream)->flushContents()->one($charStream)->importByteStream($os)->allowing($is)->write(any(), optional())->will($collection)->ignoring($is)->ignoring($os)); for ($seq = 0; $seq <= 140; ++$seq) { $this->_checking(Expectations::create()->one($charStream)->readBytes(any())->returns(array(ord('a')))); } $this->_checking(Expectations::create()->one($charStream)->readBytes(any())->returns(false)); $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); $encoder->encodeByteStream($os, $is, 22); $this->assertEqual(str_repeat('a', 53) . "=\r\n" . str_repeat('a', 75) . "=\r\n" . str_repeat('a', 13), $collection->content); }
protected function _createOutputStream($data = null, $stub = true) { $os = $this->_mock('Swift_OutputByteStream'); if (isset($data)) { $pos = $this->_mockery()->states('position')->startsAs('at beginning'); $this->_checking(Expectations::create()->ignoring($os)->read(optional())->returns($data)->when($pos->isNot('at end'))->then($pos->is('at end'))->ignoring($os)->read(optional())->returns(false)); if ($stub) { $this->_checking(Expectations::create()->ignoring($os)); } } return $os; }
<?php $isincluded = true; include 'xmoov.php'; $height = optional($_GET["height"], $cfg["media-player"]["default-height"]); $width = optional($_GET["width"], $cfg["media-player"]["default-width"]); ?> <div id="player" class="media">Please turn on JavaScript</div> <script type='text/javascript'> var s1 = new SWFObject('modules/media/player.swf','theswf','<?php echo $width; ?> ','<?php echo $height; ?> ','9', '#ffffff'); s1.addParam('allowfullscreen','true'); s1.addParam('allowscriptaccess','always'); s1.addParam('flashvars','file=<?php echo $_GET['file']; ?> &skin=<?php echo BASE_URL; ?> modules/media/schoon.swf&enablejs=true&autostart=true&bufferlength=1'); s1.write('player'); </script><!--&streamer=<?php echo BASE_URL; ?> modules/media/xmoov.php&token=<?php