Inheritance: extends Plugin
コード例 #1
0
 /**
  * Extract examples from file
  *
  * @param  \SplFileObject         $file   File to extract examples from
  * @param  Format\FormatInterface $format Format used to identify examples
  * @return Example[]
  */
 public function createExamples(\SplFileObject $file, Format\FormatInterface $format)
 {
     $exampleId = 1;
     $examples = [];
     $current = new Example($exampleId);
     $inCodeBlock = false;
     $ignoreNext = false;
     foreach ($file as $line) {
         if ($inCodeBlock) {
             if ($format->isExampleEnd($line)) {
                 $examples[$exampleId++] = $current;
                 $current = new Example($exampleId);
                 $inCodeBlock = false;
                 continue;
             }
             $current->addLine($line);
         } elseif ($format->isExampleStart($line)) {
             $inCodeBlock = true;
             if ($ignoreNext) {
                 $current = new Example(++$exampleId);
                 $ignoreNext = false;
                 $inCodeBlock = false;
             }
         } elseif ($this->isIgnoreAnnotation($line)) {
             $ignoreNext = true;
         } elseif ($expectation = $this->readExpectation($line)) {
             $current->addExpectation($expectation);
         }
     }
     return $examples;
 }
コード例 #2
0
function test()
{
    print "In test function\n";
    $example = new Example();
    $example->state = false;
    $example->setNumber(4);
    $refNum = 0;
    $example->setNumberToRef($refNum);
    print "Num: " . $refNum;
    if ($example instanceof Example) {
        print "\nInstance of Ext    ractAcademicsData\n";
    }
    $a = array(1, 2, 3, 4, 5);
    foreach ($a as $n) {
        print "\nfe> " . $n;
    }
    print "\n";
    for ($i = 0; $i < 5; $i++) {
        print "\nfc> " . $a[$i];
    }
    print "\n";
    $xA = array('one' => '1 num', 'two' => '2 num');
    foreach ($xA as $k => $v) {
        print "\nfe[" . $k . "]: " . $v;
    }
    print "\n";
}
コード例 #3
0
 /**
  * @test
  */
 public function directoryIsCreated()
 {
     $example = new Example('id');
     $this->assertFalse(file_exists(__DIR__ . '/id'));
     $example->setDirectory(__DIR__);
     $this->assertTrue(file_exists(__DIR__ . '/id'));
 }
コード例 #4
0
 public function testHello()
 {
     $example = new Example();
     $expected = 'Hello, Robert!';
     $actual = $example->hello('Robert');
     $this->assertSame($expected, $actual);
 }
コード例 #5
0
 /**
  * test that the directory is created
  */
 public function testDirectoryIsCreated()
 {
     $example = new Example('id');
     $this->assertFalse(vfsStreamWrapper::getRoot()->hasChild('id'));
     $example->setDirectory(vfsStream::url('exampleDir'));
     $this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('id'));
 }
コード例 #6
0
ファイル: ExampleTestCaseOldWay.php プロジェクト: pago/pantr
 /**
  * test that the directory is created
  */
 public function testDirectoryIsCreated()
 {
     $example = new Example('id');
     $this->assertFalse(file_exists(dirname(__FILE__) . '/id'));
     $example->setDirectory(dirname(__FILE__));
     $this->assertTrue(file_exists(dirname(__FILE__) . '/id'));
 }
コード例 #7
0
 public function example($params = null)
 {
     $min = isset($params[0]) ? $params[0] : null;
     $data['title'] = 'Example';
     $data['params'] = $params;
     $classExample = new Example();
     $data['values'] = $classExample->exampleValues($min);
     $data['lastId'] = $classExample->addValue(rand(0, 100));
     $this->view('example', $data);
 }
コード例 #8
0
ファイル: ExampleGroup.php プロジェクト: janvoracek/phew
 public function add(Example $example)
 {
     $this->examples[] = $example;
     if ($example instanceof ExampleGroup) {
         foreach ($this->examplePrepareFunctions as $prepareFunction) {
             $example->callBeforeEachExample($prepareFunction);
         }
         foreach ($this->exampleCleanupFunctions as $cleanupFunction) {
             $example->callBeforeEachExample($cleanupFunction);
         }
     }
 }
コード例 #9
0
ファイル: TestWaxModelField.php プロジェクト: phpwax/waxmodel
 public function test_validate_length()
 {
     $this->model->define("username", "CharField", array("maxlength" => "3"));
     $res = $this->model->set_attributes($this->get_fixture("user1"));
     $this->assertFalse($res->validate());
     $res = new Example();
     $res->define("username", "CharField", array("maxlength" => "6"));
     $res->set_attributes($this->get_fixture("user1"));
     $this->assertTrue($res->validate());
     $res = new Example();
     $res->define("username", "CharField", array("minlength" => "6"));
     $res->set_attributes($this->get_fixture("user1"));
     $this->assertFalse($res->validate());
 }
コード例 #10
0
function get_examples($con, $args)
{
    $examples = array();
    if (isset($args["eid"])) {
        $eid = $args["eid"];
        $sql = $con->prepare("SELECT section_id,ename,`order` FROM example WHERE eid=?");
        $sql->bind_param("i", $eid);
        $sql->bind_result($section_id, $ename, $order);
        $sql->execute();
        $sql->fetch();
        $sql->close();
        if (isset($section_id) && isset($ename) && isset($order)) {
            $tmp = new Example();
            $tmp->populate($eid, $section_id, $ename, $order);
            $examples[] = $tmp->expose();
        }
    } else {
        if (isset($args["ename"])) {
            $ename = $args["ename"];
            $sql = $con->prepare("SELECT eid,section_id,`order` FROM example WHERE ename=?");
            $sql->bind_param("s", $ename);
            $sql->bind_result($eid, $section_id, $order);
            $sql->execute();
            while ($sql->fetch()) {
                if (isset($eid) && isset($section_id) && isset($order)) {
                    $tmp = new Example();
                    $tmp->populate($eid, $section_id, $ename, $order);
                    $examples[] = $tmp->expose();
                }
            }
            $sql->close();
        } else {
            $sql = $con->prepare("SELECT eid,ename,section_id,`order` FROM example");
            $sql->bind_result($eid, $ename, $section_id, $order);
            $sql->execute();
            while ($sql->fetch()) {
                if (isset($eid) && isset($ename) && isset($section_id) && isset($order)) {
                    $tmp = new Example();
                    $tmp->populate($eid, $section_id, $ename, $order);
                    $examples[] = $tmp->expose();
                }
            }
            $sql->close();
        }
    }
    return $examples;
}
コード例 #11
0
ファイル: singleton.php プロジェクト: jenalgit/roadsend-php
 public static function singleton()
 {
     if (!isset(self::$instance)) {
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }
コード例 #12
0
ファイル: ExampleTest.php プロジェクト: najomi/najomi.org
 public function testYFMInMarkdown()
 {
     $e = new Example('example/hello.md');
     $this->assertEquals($e->desc(), 'Hello');
     $this->assertEquals($e->code(), 'ls');
     $this->assertEquals($e->file_id(), 'hello.md');
     $this->assertEquals($e->id(), 7);
     $this->assertEquals($e->ft(), 'lisp');
     $this->assertEquals($e->url(), '/example/hello.md');
 }
コード例 #13
0
 function should($assertionName, $expectedValue)
 {
     $args = func_get_args();
     $registeredAssertions = array('be equals' => '\\PSpec\\BeEquals', 'be an instance of' => '\\PSpec\\BeAnInstanceOf', 'be between' => '\\PSpec\\BeBetween', 'only have instances of' => '\\PSpec\\OnlyHaveInstancesOf');
     if (!array_key_exists($assertionName, $registeredAssertions)) {
         throw new Exception('Assertion "' . $assertionName . '" does not exists');
     }
     $assertionClass = $registeredAssertions[$assertionName];
     $assertion = new $assertionClass();
     $args[0] = $this->subject;
     $expectationResult = call_user_func_array(array($assertion, 'execute'), $args);
     Example::addExpectationResultToOpenExampleResult($expectationResult);
 }
コード例 #14
0
ファイル: ModelTest.php プロジェクト: phpwax/model
 public function test_querying()
 {
     $model = new Example();
     $backend = new MockBackend();
     $model->set_backend($backend);
     $model->filter("username", "test");
     $model->filter("username", "again", "!=");
     $model->order("testorder");
     $model->limit(5);
     $model->offset(2);
     $this->assertEquals(2, count($backend->query["filter"]));
     $this->assertEquals("testorder", $backend->query["order"]);
     $this->assertEquals(5, $backend->query["limit"]);
     $this->assertEquals(2, $backend->query["offset"]);
 }
コード例 #15
0
<?php

session_start();
function __autoload($name)
{
    require '../src/bolcom/' . $name . '.php';
}
//please fill in your API-key in Example.php before running index.php
require_once 'Example.php';
Example::run();
コード例 #16
0
ファイル: index.php プロジェクト: jortiz-el/PhP
{
    private $id;
    public function setId($id)
    {
        $this->id = $id;
    }
    public function getId()
    {
        return $this->id;
    }
}
// Creamos un objeto de la clase colección
$collection = new Collection();
// Populamos la colección con 10 objetos ejemplo
for ($i = 1; $i <= 10; $i++) {
    $example = new Example();
    $example->setId($i);
    // add the object to the collection
    $collection->add($example);
}
echo "-------------------------------------------------------------";
var_dump($collection);
echo "-------------------------------------------------------------<br>";
// Obtenemos el primer objeto de la colección
echo "-------------------------------------------------------------";
$first = $collection->getCurrent();
var_dump($first);
echo "-------------------------------------------------------------<br>";
//Avanzar el cursos y obtener el segundo elemento
echo "-------------------------------------------------------------";
$collection->next();
コード例 #17
0
ファイル: access_modifiers.php プロジェクト: Keav/phpcms
<?php

class Example
{
    public $a = 1;
    protected $b = 2;
    private $c = 3;
    function show_abc()
    {
        echo $this->a;
        echo $this->b;
        echo $this->c;
    }
}
$example = new Example();
// echo "public a: {$example->a}<br />";
$example->show_abc();
echo "<br />";
class smallExample extends Example
{
    protected $b = 6;
}
$example2 = new smallExample();
$example2->show_abc();
コード例 #18
0
ファイル: CommandTest.php プロジェクト: danzabar/alice
 /**
  * Test the isolated command functions
  *
  * @return void
  * @author Dan Cox
  */
 public function test_isolateExample()
 {
     $command = new Example();
     $this->assertEquals('example:command', $command->getName());
     $this->assertEquals('The example description', $command->getDescription());
 }
コード例 #19
0
ファイル: SoftMocksExample.php プロジェクト: badoo/soft-mocks
 public static function run()
 {
     $result = ['TEST_CONSTANT_WITH_VALUE_42' => TEST_CONSTANT_WITH_VALUE_42, 'someFunc(2)' => someFunc(2), 'Example::doSmthStatic()' => Example::doSmthStatic(), 'Example->doSmthDynamic()' => (new Example())->doSmthDynamic(), 'Example::STATIC_DO_SMTH_RESULT' => Example::STATIC_DO_SMTH_RESULT];
     return $result;
 }
コード例 #20
0
ファイル: index.php プロジェクト: najomi/najomi.org
<?php

if (!path()) {
    draw_page('Поваренная книга программиста', dview('index_content', main_categories()));
} elseif (is_category_path(path()) && is_category_exists(path())) {
    is_need_cache(true);
    $category = new Category(path());
    keywords($category->keywords());
    draw_page($category->getTitle(), dview('one_category', $category));
} elseif (is_example_path(path()) && is_example_exists(path())) {
    is_need_cache(true);
    $example = new Example(path());
    keywords($example->keywords());
    draw_page($example->prop('desc'), view('path_block', ['id' => $example->id()]) . view('one_example', ['data' => $example, 'show_link' => true]));
} else {
    show_404();
}
コード例 #21
0
 public function testExample()
 {
     $exmp = new Example();
     $this->assertEquals(strpos($exmp->test(), 'h') == 2, true);
 }
コード例 #22
0
ファイル: example.php プロジェクト: hanccc/crawler
        if (preg_match('/共(\\d+)页/', $this->crawler->filter('.co_content8 .x')->text(), $match)) {
            $this->maxPage = $match[1];
        }
    }
}
class YgdyDetailCrawler extends \Hanccc\DetailCrawler
{
    /**
     * @param $url string
     * @return bool
     */
    public function isDetailUrl($url)
    {
        return preg_match('/gndy\\/dyzz\\/(\\d+)\\/(\\d+).html/', $url);
    }
    public function handle()
    {
        echo $this->crawler->filter('title')->text() . PHP_EOL;
    }
}
class Example
{
    function test()
    {
        $listCrawler = new YgdyListCrawler(__DIR__ . '/');
        $listCrawler->setDetailCrawler(new YgdyDetailCrawler());
        $listCrawler->start();
    }
}
$test = new Example();
$test->test();
コード例 #23
0
ファイル: index.php プロジェクト: hielsnoppe/php-goodies
<?php

namespace NielsHoppe\Goodies\JsonSchema;

require 'vendor/autoload.php';
$main = new Example('Fridolin');
print_r($main->jsonSerialize());
コード例 #24
0
 public function index()
 {
     $message = Example::get_data();
     View::render('index', ['message' => $message]);
 }
    public function hello_everyone()
    {
        return "Hello Everyone<br/>";
    }
    private function hello_me()
    {
        return "Hello Me<br/>";
    }
    protected function hello_family()
    {
        return "Hello Family<br/>";
    }
    // public by default
    function hello()
    {
        $output = $this->hello_everyone();
        $output .= $this->hello_family();
        $output .= $this->hello_me();
        return $output;
    }
}
$example = new Example();
echo "Public a: {$example->a} <br/>";
//echo "Private c: {$example->c} <br/>";
//echo "Protected b: {$example->b} <br/>";
$example->show_abc();
echo "<br/>";
echo "Hello Everyone: {$example->hello_everyone()} <br/>";
//echo "Hello Family: {$example->hello_family()}<br/>";
//echo "Hello Me: {$example->hello_me()}<br/>";
echo $example->hello();
コード例 #26
0
 public function testSomething()
 {
     $example = new Example();
     $this->assertEquals($example->foo(), 'bar');
 }
コード例 #27
0
<?php

class Example
{
    /**
     * This is myMethod!
     *
     * @param   string|array  $s  param1
     * @param   int           $i  param2
     * @param   Example|null  $e  param3
     * @param   bool          $b  param4
     * @param   array/null    $a  param5
     * @return  array|bool    Returns FALSE if error occurred
     */
    public function myMethod($s, $i, $e = null, $b = true, array $a = null)
    {
        if (!ReflectionTypeHint::isValid()) {
            return false;
        }
        //...
    }
}
Example::myMethod('sss', 75467, $e, true);
$e = new Example();
//$e->myMethod('sss', 75467, new Exception(), true);
コード例 #28
0
<?php

// require the file that includes the class definition
require_once "simpleclass1.php";
// create a new instance of the Example class (instantiate
// is the term // often used)
$example = new Example("Rob");
// call the greeting method
$example->greeting("Hello, how are you?");
//echo "<p>This is the client referring to the name attribute:
//     $example->name</p>\n";
echo "<p>This is the client using a method to retrieve the name attribute: " . $example->getName() . "</p>\n";
コード例 #29
0
 public static function run()
 {
     $bol_api_key = '0A1C1E282CB14EF2BB8722AD2FABAABB';
     $bol_api_format = 'json';
     $bol_api_debug_mode = 0;
     $bol_api_library_version = 'v.2.0.0';
     self::$bol_partner_site_id = '12345';
     self::$apiClient = new Client($bol_api_key, $bol_api_format, $bol_api_debug_mode);
     $servername = str_replace("www.", "", $_SERVER['SERVER_NAME']);
     self::$rooturl = 'http://' . $servername . $_SERVER['SCRIPT_NAME'];
     // convert html characters in $_REQUEST params for Cross-site scripting (XSS)
     foreach ($_REQUEST as $key => $value) {
         $params[$key] = htmlspecialchars($value);
     }
     // get action param for which data to get or post
     $action = isset($params['action']) ? $params['action'] : "search";
     switch ($action) {
         case 'default':
             self::ping();
             break;
         case 'getproduct':
             self::getProduct(false, $params);
             break;
         case 'getproductraw':
             self::getProduct(true, $params);
             break;
         case 'getrecommendations':
             self::getRecommendations(false, $params);
             break;
         case 'getrecommendationsraw':
             self::getRecommendations(true, $params);
             break;
         case 'getrelatedproducts':
             self::getRelatedProducts(false, $params);
             break;
         case 'getrelatedproductsraw':
             self::getRelatedProducts(true, $params);
             break;
         case 'getoffer':
             self::getOffer(false, $params);
             break;
         case 'getofferraw':
             self::getOffer(true, $params);
             break;
         case 'getlists':
             self::getLists(false, $params);
             break;
         case 'getlistsraw':
             self::getLists(true, $params);
             break;
         case 'search':
             return self::search(false, $params);
             break;
         case 'searchraw':
             self::search(true, $params);
             break;
         case 'sellerlists':
             self::getSellerlists(false, $params);
             break;
         case 'sellerlistsraw':
             self::getSellerlists(true, $params);
             break;
         case 'postbasket':
             self::postBasket();
             break;
         case 'getbasket':
             self::getBasket();
             break;
         case 'getbasketraw':
             self::getBasket(true);
             break;
         case 'updatequantitybasket':
             self::updateQuantityBasket(false, $params);
             break;
         case 'removefrombasket':
             self::removefromBasket(false);
             break;
         case 'addanotheritemtobasket':
             self::addAnotherItemToBasket(false, $params);
             break;
         case 'authtoken':
             self::getAuthTokens(false);
             break;
         case 'authtokenraw':
             self::getAuthtokens(true);
             break;
         case 'authtokenSuccess':
             self::getAuthtokensSuccess();
             break;
         case 'authtokenError':
             self::getAuthtokensError();
             break;
         case 'login':
             self::getLogin(false, $params);
             break;
         case 'getwishlist':
             self::getWishlist(false);
             break;
         case 'getwishlistraw':
             self::getWishlist(true);
             break;
         case 'postwishlist':
             self::postWishlist(false);
             break;
         case 'deletewishlist':
             self::deleteWishlist();
             break;
         case 'setRefferer':
             self::setRefferer(false);
             break;
         case 'setReffererraw':
             self::setRefferer(true);
             break;
         case 'setSession':
             self::setSession();
             break;
         case 'destroySession':
             self::destroySession();
             break;
     }
 }
コード例 #30
0
ファイル: examples.php プロジェクト: Nehamkin/processing-docs
                    $ex->output_file($catBasics);
                } else {
                    $ex->output_file($catBasics, "../../");
                }
                $count++;
            }
        }
    }
}
//Create Topics files
$count = 0;
foreach ($catTopics as $cat => $array) {
    if ($dp = opendir($dirTopics . $cat)) {
        while ($fp = readdir($dp)) {
            if (substr($fp, 0, 1) != '.') {
                $ex = new Example($fp, "Topics/" . $cat, $subdir);
                if (!$local) {
                    $ex->output_file($catTopics);
                } else {
                    $ex->output_file($catTopics, "../../");
                }
                $count++;
            }
        }
    }
}
//Create Examples page
$page = new Page('Examples', 'Examples', "", "../../");
$page->subtemplate('template.examples-main.html');
//Create Basics html
$html = "<b>Basic Examples</b>. <i>Programs about form, data, images, color, typography, and more...</i><br /><br /><br />";