示例#1
0
<?php

describe("Spec", function () {
    $this->value = "hello";
    it("should have value", function () {
        assert($this->value == "hello", "there should be value");
    });
    it("should have a passing spec", function () {
    });
    xit("should have a failing spec", function () {
        throw new Exception("failure");
    });
    it("should be pending");
    beforeEach(function () {
        $this->thing = new ArrayObject();
    });
    describe('A nested suite', function () {
        beforeEach(function () {
            $this->thing->append('hello');
        });
        beforeEach(function () {
            $this->thing->append('goodbye');
        });
        it('should have access to thing', function () {
            assert($this->thing[0] == "hello", 'hello should be a thing');
            assert($this->thing[1] == "goodbye", "goodbye should be a thing");
        });
    });
});
示例#2
0
 public function tests()
 {
     PHPUsableTest::$current_test = $this;
     describe('with esperance style assertions', function ($test) {
         describe('with a true value', function ($test) {
             before(function ($test) {
                 //Arbitratry variables can be stored on test to pass between blocks
                 $test->my_value = true;
             });
             it('should be true', function ($test) {
                 $test->expect($test->my_value)->to->be->ok();
             });
         });
         describe('with a false value', function ($test) {
             before(function ($test) {
                 $test->my_value = false;
             });
             it('should be false', function ($test) {
                 $test->expect($test->my_value)->to->be(false);
             });
         });
     });
     describe('with phpunit style assertions', function ($test) {
         describe('with a true value', function ($test) {
             before(function ($test) {
                 $test->my_value = true;
             });
             it('should be true', function ($test) {
                 $test->assertTrue($test->my_value);
             });
         });
         describe('with a false value', function ($test) {
             before(function ($test) {
                 $test->my_value = false;
             });
             it('should be false', function ($test) {
                 $test->assertFalse($test->my_value);
             });
         });
     });
     describe('with mock expectations', function ($test) {
         before(function ($test) {
             $test->mock = $test->getMock('simple_mock', array('test_method'));
             $test->mock->expects($test->once())->method('test_method')->will($test->returnValue('hello world!'));
         });
         it('should return the expected value', function ($test) {
             $test->assertEquals($test->mock->test_method(), 'hello world!');
         });
         it('should fail when it is not called', function ($test) {
             $test->markTestIncomplete('Some graceful manner needs to be found to indicate that this is expected to fail');
         });
     });
     describe('with expected exceptions', function ($test) {
         it('should not error out', function ($test) {
             $test->setExpectedException('Exception');
             throw new \Exception();
         });
     });
     describe('disabled specs', function ($test) {
         it('should not get fatal, without test body');
         xit('should not error out with xit', function ($test) {
             throw new \Exception();
         });
         describe('entry describe without body');
         xdescribe('entry describe with x', function ($test) {
             it('should not error out with it', function ($test) {
                 throw new \Exception();
             });
             describe('inner describe', function ($test) {
                 it('should be also disabled', function ($test) {
                     throw new \Exception();
                 });
             });
             describe('multiple inner describe', function ($test) {
                 it('should be also disabled', function ($test) {
                     throw new \Exception();
                 });
             });
         });
         it('should not stack on disabled state', function ($test) {
             $test->assertTrue(true);
         });
         it('should also mark incomplete when it does not have any expectation', function ($test) {
         });
     });
     describe('should use when method', function ($test) {
         when('there are several case with the same result', function ($test) {
             $test->assertTrue(true);
         });
     });
 }
示例#3
0
         });
     })->toThrow(new RuntimeException());
 });
 // Disabled because Monkey::patch doesn't work on included files
 xit('emit response to beyond', function () {
     Monkey::patch('header', function (string $header, bool $replace = TRUE) {
         static $first = TRUE;
         static $reset = TRUE;
         if ($first) {
             expect($header)->toBe('HTTP/1.1 202');
             $first = FALSE;
         } else {
             expect($replace)->toBe($reset);
             $reset = FALSE;
         }
     });
     Monkey::patch('headers_sent', function () {
         return FALSE;
     });
     expect(function () {
         emit(new ServerRequest(), function (ServerRequest $req, callable $open) {
             $name = $req->getQuery()['name'] ?? 'World';
             $open(202, ['Content-Language' => ['en', 'es']]);
             (yield "Hola {$name}");
         });
     })->toEcho('Hola World');
 });
 it('calls responder\'s return', function () {
     $closed = FALSE;
     emit(new ServerRequest(), function (ServerRequest $req, callable $open) use(&$closed) {
         (yield '');
示例#4
0
     /*if($hitung==0){
           $hitung=$rdata['jumlahpesan'];
           $jmlclose=0;
       }else{
           //exit("error:".$rdata['kodebarang']."__masuk sini".$rdata['jumlahpesan']."__".$angkPengurang);
           $jmlclose=$hitung;
           $hitung=0;  
       }*/
     $subTotal += $hitung * $rdata['hargasbldiskon'];
     $supdate = "update " . $dbname . ".log_podt set jmlhstlhclose='" . $jmlclose . "',jumlahpesan='" . $hitung . "'\n                                where nopo='" . $_POST['nopo'] . "' and kodebarang='" . $rdata['kodebarang'] . "'";
     if (!mysql_query($supdate)) {
         exit("error:db error " . mysql_error($conn) . "___" . $supdate);
     } else {
         $sup = "update " . $dbname . ".log_prapodt set create_po=0,status=0 where nopp='" . $rdata['nopp'] . "' and kodebarang='" . $rdata['kodebarang'] . "' ";
         if (!mysql_query($sup)) {
             xit("error:db error " . mysql_error($conn) . "___" . $sup);
         }
     }
 }
 $sHt = "select distinct diskonpersen,subtotal,nilaidiskon,ppn from " . $dbname . ".log_poht where nopo='" . $_POST['nopo'] . "'";
 $qHt = mysql_query($sHt) or die(mysql_error($conn));
 $rHt = mysql_fetch_assoc($qHt);
 $persenPPn = $rHt['ppn'] / ($rHt['subtotal'] - $rHt['nilaidiskon']) * 100;
 @($nilDis = $subTotal * $rHt['diskonpersen'] / 100);
 @($ppn = ($subTotal - $nilDis) * intval($persenPPn) / 100);
 $nilTotal = $subTotal - $nilDis + $rHt['ongkirimppn'] + $rHt['ongkosangkutan'] + $ppn;
 //$isiketerangan='';
 $supdateht = "update " . $dbname . ".log_poht set " . "closed=1,keteranganclose='" . $isiketerangan . "',userclosed='" . $_SESSION['standard']['userid'] . "',nilaidiskon='" . $nilDis . "' " . ",subtotal='" . $subTotal . "',ppn='" . $ppn . "',nilaipo='" . $nilTotal . "' " . "where nopo='" . $_POST['nopo'] . "'";
 if (!mysql_query($supdateht)) {
     exit("error:db error " . mysql_error($conn) . "___" . $supdateht);
 }
示例#5
0
     $ctx->admins = $admins;
 });
 it('should set the bob user', function ($ctx) {
     $ctx->sibling_value = 10;
     expect($ctx->bob)->to->be->a('Matura\\Test\\User');
 });
 it('should not inherit a sibling\'s context modifications', function ($ctx) {
     expect($ctx->sibling_value)->to->be(null);
 });
 it('should set the admins group', function ($ctx) {
     expect($ctx->admins)->to->be->a('Matura\\Test\\Group');
 });
 it('should skip this test when invoked', function ($ctx) {
     skip();
 });
 xit('should skip this test when constructed', function ($ctx) {
 });
 // This test is expected to fail.
 it('should be strict about undefined variables', function ($ctx) {
     $arr = array(0);
     $result = $arr[0] + $arr[1];
 });
 // Nested blocks help organize tests and allow progressive augmentation of
 // test context.
 describe('Inner Block with Before All and Context Clobbering', function ($ctx) {
     before_all(function ($ctx) {
         // Do something costly like purge and re-seed a database.
         $ctx->purged_database = true;
     });
     before(function ($ctx) {
         $ctx->admins = new Group('modified_admins');
     });