/**
  * @since  3.0.0
  * @group  issue_58
  * @test
  */
 public function stoppingAnnotationPersistenceDoesNotWriteCacheFileOnShutdown()
 {
     AnnotationCache::put(new Annotations('someTarget'));
     AnnotationCache::stop();
     AnnotationCache::__shutdown();
     assertFalse(file_exists(vfsStream::url('root/annotations.cache')));
 }
示例#2
0
 public function test_it_disables()
 {
     $DvsMagicMode = new DvsMagicMode();
     $DvsMagicMode->disable(true);
     assertFalse($DvsMagicMode->enabled());
     assertTrue($DvsMagicMode->disabled());
 }
 public function testServiceAliasDefinition()
 {
     $definition = new ServiceDefinition('service_name', ['service' => __CLASS__]);
     assertTrue($definition->isAlias());
     assertFalse($definition->isFactory());
     assertSame(__CLASS__, $definition->getClass());
 }
示例#4
0
 public function testExistingChildren()
 {
     // --- test load
     $this->createModels(CustomerDetail::class, []);
     $this->createModels(Customer::class, [['name' => 'Frank', 'surname' => 'Sinatra']]);
     $details = new CustomerDetail();
     $source = Datasource::make(new CustomerDetail());
     $source['id'] = 1;
     $source['biography'] = 'A nice life!';
     $source['accepts_cookies'] = 0;
     $source['customer_id'] = 1;
     $details->id = 1;
     $details->biography = 'A nice life!';
     $details->accepts_cookies = 0;
     $details->customer_id = 1;
     $source->save();
     assertTrue(isset($source['customer']));
     assertInstanceOf(Customer::class, $source['customer']);
     assertModelArrayEqual(Customer::all()->toArray(), [$source['customer']->toArray()]);
     // compare with how eloquent behaves:
     $this->createModels(CustomerDetail::class, []);
     $details->save();
     assertFalse(isset($details->customer));
     // always false!
     assertInstanceOf(Customer::class, $details->customer);
 }
示例#5
0
 public function test_sanity_check_fails_when_src_directory_fails()
 {
     $this->MockSanityChecksScaffolding->shouldReceive('checkViewsDirectory')->times(1)->andReturn(true);
     $this->MockSanityChecksScaffolding->shouldReceive('checkSrcDirectory')->times(1)->andReturn(false);
     $result = $this->MockSanityChecksScaffolding->runSanityCheck($this->constants, [], []);
     assertFalse($result);
 }
 function testInstance()
 {
     $faber = F::instance('test');
     $faber['foo'] = function () {
         return new Stub();
     };
     $faber2 = F::instance('test');
     $faber3 = F::instance('test2');
     $faber3['foo'] = function () {
         return new Stub();
     };
     $a = $faber['foo'];
     $b = $faber['foo'];
     $c = $faber2['foo'];
     $d = $faber3['foo'];
     assertInstanceOf('GM\\Faber\\Tests\\Stub', $a);
     assertInstanceOf('GM\\Faber\\Tests\\Stub', $b);
     assertInstanceOf('GM\\Faber\\Tests\\Stub', $c);
     assertInstanceOf('GM\\Faber\\Tests\\Stub', $d);
     assertTrue($a === $b);
     assertTrue($b === $c);
     assertFalse($c === $d);
     assertTrue($faber === $faber2);
     assertFalse($faber2 === $faber3);
 }
        public function testState()
        {
            assertNull($this->objMath->getFirstOperand());
            assertNull($this->objMath->getSecondOperand());
            assertNull($this->objMath->getFirstOperator());
            assertNull($this->objMath->getSecondOperator());

            assertFalse( $this->objMath->validate() );
            
            $this->objMath->setFirstOperand('5');
            $this->objMath->setFirstOperator('+');
            $this->objMath->setSecondOperand('2');

            assertNotNull($this->objMath->getFirstOperand());
            assertNotNull($this->objMath->getSecondOperand());
            assertNotNull($this->objMath->getFirstOperator());
            assertNotNull($this->objMath->getSecondOperator());

            assertTrue( $this->objMath->validate() );

            $this->objMath->clear( );

            assertNull($this->objMath->getFirstOperand());
            assertNull($this->objMath->getSecondOperand());
            assertNull($this->objMath->getFirstOperator());
            assertNull($this->objMath->getSecondOperator());
            
        }
 /**
  * @test
  * @profile fork
  */
 public function testParse()
 {
     split_time('Reset');
     $annotations = Annotations::get('Components\\Type_Test_Unit_Case_Annotations_Entity');
     split_time('Invoke Annotations::get(Components\\Type_Test_Unit_Case_Annotations_Entity)');
     $annotations = Annotations::get('Components\\Type_Test_Unit_Case_Annotations_Entity');
     split_time('Invoke Annotations::get(Components\\Type_Test_Unit_Case_Annotations_Entity)');
     assertTrue($annotations->hasTypeAnnotation(Annotation_Name::NAME));
     split_time('Invoke Annotations$hasMethodAnnotation(name)');
     assertTrue($annotations->hasTypeAnnotation(Annotation_Name::NAME));
     split_time('Invoke Annotations$hasMethodAnnotation(name)');
     assertTrue($annotations->hasTypeAnnotation('package'));
     split_time('Invoke Annotations$hasMethodAnnotation(package)');
     assertFalse($annotations->hasTypeAnnotation('version'));
     split_time('Invoke Annotations$hasMethodAnnotation(version)');
     assertTrue($annotations->hasMethodAnnotation('poke', Annotation_Name::NAME));
     split_time('Invoke Annotations$hasMethodAnnotation(poke)');
     assertTrue($annotations->hasMethodAnnotation('poke', Annotation_Name::NAME));
     split_time('Invoke Annotations$hasMethodAnnotation(poke)');
     $pokeName = $annotations->getMethodAnnotation('poke', Annotation_Name::NAME);
     split_time('Invoke Annotations$getMethodAnnotation(poke)');
     $pokeName = $annotations->getMethodAnnotation('poke', Annotation_Name::NAME);
     split_time('Invoke Annotations$getMethodAnnotation(poke)');
     $annotations = Annotations::get(__CLASS__);
     split_time('Invoke Annotations::get(' . __CLASS__ . ')');
     $annotations = Annotations::get(__CLASS__);
     split_time('Invoke Annotations::get(' . __CLASS__ . ')');
     assertEquals('poke', $pokeName->value);
 }
示例#9
0
 public function test_it_cant_create_new_page()
 {
     $this->PageVersionManager->shouldReceive('createDefaultPageVersion')->times(0);
     $page = $this->ApiPagesManager->createNewPage(['title' => 'Some page title', 'slug' => '/some-page-title', 'http_verb' => 'get']);
     assertFalse($page);
     assertEquals(count($this->ApiPagesManager->errors), 1);
 }
示例#10
0
 public function testCanValidatePasswordWithSymbols()
 {
     $validator = $this->createValidator();
     $validator->setMinSymbols(2);
     assertTrue($validator->isValid('!pass.word'));
     assertFalse($validator->isValid('1N3RD007'));
 }
 /**
  * @param string $error
  *
  * @Then /^I should not see(?: a)? validation (?:error|tooltip) "([^"]*)"$/
  */
 public function iShouldNotSeeValidationError($error)
 {
     if ($this->getSession()->getDriver() instanceof Selenium2Driver) {
         $script = 'return $(\'.validation-tooltip[data-original-title="%s"]\').length > 0';
         $found = $this->getSession()->evaluateScript(sprintf($script, $error));
         assertFalse($found, sprintf('Expecting to not see validation error, "%s" found', $error));
     }
 }
 function testChangingPassword()
 {
     $userB4 = $this->loginAsNormalUser();
     assertFalse(Passwords\isValid('n00p@ss', $userB4->passwordEncrypted));
     $this->get('/account/change-password');
     $this->submitForm($this->getForm('change-password-form'), array('current-password' => 'abc123', 'password' => 'n00p@ss', 'confirm-password' => 'n00p@ss'));
     $userAfter = User::loadFromID($userB4->id);
     assertTrue(Passwords\isValid('n00p@ss', $userAfter->passwordEncrypted));
 }
示例#13
0
 public function test_it_tells_us_if_we_are_not_in_groups()
 {
     $this->Framework->Auth->shouldReceive('check')->times(3)->andReturn(true);
     $currentUser = $this->DvsUser->find(1);
     $this->Framework->Auth->shouldReceive('user')->andReturn($currentUser);
     assertTrue($this->RuleList->isNotInGroups('Group1', 'Group2'));
     assertTrue($this->RuleList->isNotInGroups('Developer', 'Group1'));
     assertFalse($this->RuleList->isNotInGroups('Developer', 'Developer'));
 }
示例#14
0
function testDeterminingWhetherWidgetHasEndedOrNot()
{
    $w = getWidget();
    $w->ending = new DateTime('-1 day');
    assertTrue($w->hasEnded());
    $w->ending = new DateTime((new DateTime('now'))->format('Y-m-d'));
    assertFalse($w->hasEnded());
    $w->ending = new DateTime('+1 day');
    assertFalse($w->hasEnded());
}
示例#15
0
 /**
  * A user that isn't logged in shouldn't see the "Your Account" menu (including, "Your Widgets",
  * "Change Password", etc).
  */
 function testSigninYourAccountMenuIsNotDisplayedToNonAuthenticatedUser()
 {
     $this->createHomepageWidgets();
     $this->get('/account/signout');
     $this->get('/');
     assertFalse(contains($this->currentPageContent(), "Your Account"));
     assertFalse(contains($this->currentPageContent(), "Change Password"));
     assertFalse(contains($this->currentPageContent(), "Sign Out"));
     assertTrue(contains($this->currentPageContent(), "Sign In"));
 }
示例#16
0
 function testEndingWidget()
 {
     $w = getWidget($this->user);
     $this->updateEndingDate($w, new DateTime('+7 days'));
     assertFalse($w->hasEnded());
     $this->get('/dashboard/');
     $this->clickLink("//a[contains(text(), 'End') and contains(@href, '{$w->id}')]");
     $this->submitForm($this->getForm('end-widget-' . $w->id));
     $wNow = Widget::getByID($w->id);
     assertTrue($wNow->hasEnded());
 }
示例#17
0
 /**
  * @covers Mobileka\MosaiqHelpers\MosaiqArray::find
  */
 public function test_finds_first_truthy_element()
 {
     $badArray = [0, false, '', null];
     $oneArray = [0, 1];
     $stringArray = [null, false, 'Mosaiq Soft'];
     $badNestedArray = [null, false, 'Mosaiq Soft' => []];
     $goodNestedArray = [null, false, 'Mosaiq Soft' => ['test' => ['hoo!']]];
     assertNull(MosaiqArray::make($badArray)->find());
     assertFalse(MosaiqArray::make($badArray)->find(false));
     assertEquals(1, MosaiqArray::make($oneArray)->find());
     assertEquals('Mosaiq Soft', MosaiqArray::make($stringArray)->find());
     assertNull(MosaiqArray::make($badNestedArray)->find());
     assertEquals(['test' => ['hoo!']], MosaiqArray::make($goodNestedArray)->find());
 }
示例#18
0
 /** 
  * Basic test. Check that most recent contest is at the top of the list
  */
 public function testLatestPublicContest()
 {
     $r = new Request();
     // Create new PUBLIC contest
     $contestData = ContestsFactory::createContest();
     // Log as a random contestant
     $contestant = UserFactory::createUser();
     $r["auth_token"] = $this->login($contestant);
     $response = ContestController::apiList($r);
     // Assert our contest is there.
     foreach ($response['results'] as $contest) {
         if ($contest['title'] == $contestData['request']['title']) {
             return;
         }
     }
     assertFalse(TRUE, 'Array does not contain created contest');
 }
 public function testConstrunct()
 {
     try {
         $ossClient = new OssClient(Config::OSS_ACCESS_ID, Config::OSS_ACCESS_KEY, Config::OSS_ENDPOINT);
         $this->assertFalse($ossClient->isUseSSL());
         $ossClient->setUseSSL(true);
         $this->assertTrue($ossClient->isUseSSL());
         $this->assertTrue(true);
         $this->assertEquals(3, $ossClient->getMaxRetries());
         $ossClient->setMaxTries(4);
         $this->assertEquals(4, $ossClient->getMaxRetries());
         $ossClient->setTimeout(10);
         $ossClient->setConnectTimeout(20);
     } catch (OssException $e) {
         assertFalse(true);
     }
 }
示例#20
0
 public function testConstrunct()
 {
     try {
         $ossClient = new OssClient('id', 'key', 'http://oss-cn-hangzhou.aliyuncs.com');
         $this->assertFalse($ossClient->isUseSSL());
         $ossClient->setUseSSL(true);
         $this->assertTrue($ossClient->isUseSSL());
         $this->assertTrue(true);
         $this->assertEquals(3, $ossClient->getMaxRetries());
         $ossClient->setMaxTries(4);
         $this->assertEquals(4, $ossClient->getMaxRetries());
         $ossClient->setTimeout(10);
         $ossClient->setConnectTimeout(20);
     } catch (OssException $e) {
         assertFalse(true);
     }
 }
示例#21
0
 function testSignupProcess()
 {
     $this->createHomepageWidgets();
     $this->get('/');
     $this->clickLink("//a[contains(@href, 'signup')]");
     $this->get('/account/signup');
     $this->followRedirects(true);
     $this->submitForm($this->getForm(), array('username' => 'sammy', 'email' => '*****@*****.**', 'password1' => 'luckystars', 'password2' => 'luckystars', 'memorydealers-updates' => 'on'));
     $u = User::loadFromUsername('sammy');
     assertEqual('*****@*****.**', $u->email);
     $subscriptions = current(DB\simpleSelect('subscriptions', 'user_id = ?', array($u->id)));
     assertFalse(empty($subscriptions), 'Expected to find record in subscriptions table for user');
     assertTrue($subscriptions['chipin'] == false || $subscriptions['chipin'] == 0);
     assertTrue($subscriptions['memorydealers'] == true || $subscriptions['memorydealers'] == 1);
     $this->logout();
     $this->login('sammy', 'luckystars');
     $this->get('/dashboard/');
     assertTrue(beginsWith($this->getCurrentPath(), '/dashboard'));
 }
示例#22
0
 public function testIssetUnset()
 {
     $obj = new \stdClass();
     $obj->data = [];
     $attribute = ArrayAttribute::make($obj, $obj->data, 'test', []);
     assertFalse(isset($attribute['hello']));
     assertFalse(isset($obj->data['test']['hello']));
     $attribute['hello'] = 'world';
     $this->assertEquals('world', $attribute['hello']);
     $this->assertEquals('world', $obj->data['test']['hello']);
     assertTrue(isset($attribute['hello']));
     assertTrue(isset($obj->data['test']['hello']));
     $attribute['hello'] = null;
     $this->assertEquals(null, $attribute['hello']);
     $this->assertEquals(null, $obj->data['test']['hello']);
     // this is how PHP behaves
     assertFalse(isset($attribute['hello']));
     assertFalse(isset($obj->data['test']['hello']));
 }
示例#23
0
 public function testExistingChildren()
 {
     // --- test load
     $this->createModels(Customer::class, []);
     $this->createModels(Order::class, [['code' => 'a1', 'shipping' => 'home', 'customer_id' => 1], ['code' => 'b1', 'shipping' => 'office', 'customer_id' => 1]]);
     $customer = new Customer();
     $source = Datasource::make(new Customer());
     $source['id'] = 1;
     $source['name'] = 'Frank';
     $source['surname'] = 'Sinatra';
     $source->save();
     // this is how eloquent behaves (always false)
     assertFalse(isset($customer->orders));
     // this is how datasource behaves (always true)
     assertTrue(isset($source['orders']));
     assertInstanceOf(Collection::class, $customer->orders);
     assertInstanceOf(Collection::class, $source['orders']);
     assertModelArrayEqual(Order::all(), $source['orders']);
     // don't do this at home, folks :)
     assertSame('Frank', $source['orders.0.customer.name']);
     assertSame('Frank', $source['orders.0.customer.orders.0.customer.name']);
 }
 /**
  * @Then /^after merging them I\'m expecting one result with:$/
  */
 public function afterMergingThemIMExpectingOneResultWith(TableNode $table)
 {
     $result = new ParserResult();
     foreach ($this->results as $r) {
         $result->mergeWithResult($r);
     }
     $warningsCount = $examplesCount = 0;
     foreach ($table->getHash() as $row) {
         $file = $row['test-file'];
         $warningsCount += count(explode(', ', $row['warning']));
         $examplesCount += count(explode(', ', $row['examples']));
         assertEquals(explode(', ', $row['warning']), $result->getWarnings($file));
         assertEquals(explode(', ', $row['examples']), $result->getExamples($file));
         assertEquals($row['result'], $result->getResult($file));
         if ($row['skip']) {
             assertTrue($result->isSkipped($file));
         } else {
             assertFalse($result->isSkipped($file));
         }
     }
     assertEquals($warningsCount, $result->countAllWarnings());
     assertEquals($examplesCount, $result->countAllExamples());
 }
示例#25
0
 public function testExistingChildren()
 {
     // --- test load
     $this->createModels(Order::class, []);
     $this->createModels(Book::class, [['title' => 'Happiness'], ['title' => 'Delight']]);
     $this->createPivot('book_order', [['book_id' => 1, 'order_id' => 1], ['book_id' => 2, 'order_id' => 1]]);
     $order = new Order();
     $source = Datasource::make(new Order());
     $source['id'] = 1;
     $source['code'] = 'a1';
     $source['shipping'] = 'home';
     $source['customer_id'] = 1;
     $source->save();
     // this is how eloquent behaves (always false)
     assertFalse(isset($order->books));
     // this is how datasource behaves (always true)
     assertTrue(isset($source['books']));
     assertInstanceOf(Collection::class, $order->books);
     assertInstanceOf(Collection::class, $source['books']);
     assertModelArrayEqual(Book::all()->toArray(), $source['books']->toArray());
     // don't do this at home, folks :)
     assertSame('Happiness', $source['books.0.orders.0.books.0.title']);
     assertSame('Happiness', $source['books.0.orders.0.books.0.orders.0.books.0.orders.0.books.0.title']);
 }
 /**
  * @test
  * @profile(fork)
  */
 public function testDetectors()
 {
     assertTrue(\str\isNullOrEmpty(null));
     assertTrue(\str\isNullOrEmpty(''));
     assertFalse(\str\isNullOrEmpty('0.00'));
     assertFalse(\str\isNullOrEmpty('00000'));
     assertFalse(\str\isNullOrEmpty('0.001'));
     assertFalse(\str\isNullOrEmpty('f'));
     assertFalse(\str\isNullOrEmpty('foo'));
     assertTrue(\str\isNullOrZero(null));
     assertTrue(\str\isNullOrZero(''));
     assertTrue(\str\isNullOrZero('0.00'));
     assertTrue(\str\isNullOrZero('00000'));
     assertFalse(\str\isNullOrZero('0.001'));
     assertFalse(\str\isNullOrZero('f'));
     assertFalse(\str\isNullOrZero('foo'));
     assertTrue(\str\isZero('0.00'));
     assertTrue(\str\isZero('00000'));
     assertFalse(\str\isZero(null));
     assertFalse(\str\isZero(''));
     assertFalse(\str\isZero('0.001'));
     assertFalse(\str\isZero('f'));
     assertFalse(\str\isZero('foo'));
 }
示例#27
0
$node = $_ALF_MODEL["testNode"];
assertNotNull($node, "testNode model value was found to be null");
$folder = $_ALF_MODEL["testFolder"];
assertNotNull($folder, "testFolder model value was found to be null");
// Test changing the properties of the node
$node->cm_name = "changed.txt";
$node->cm_author = "Mr Trouble";
// Add aspect
$node->addAspect("cm_titled", array("cm_title" => "my title", "cm_description" => "my description"));
// Remove aspect
$node->removeAspect("cm_versionable");
// Create a child node
$newNode1 = $folder->createChild("cm_content", "cm_contains", "cm_file.txt");
$newNode1->cm_name = "file.txt";
$newNode1->addAspect("sys_referenceable", array());
// Create another child node
$newNode2 = $folder->createChild("cm_folder", "cm_contains", "cm_testFolder");
$newNode2->cm_name = "testFolder";
// Add a non-primary child
$newNode2->addChild($node, "cm_contains", "cm_myNode");
// Associate the two nodes together
$newNode1->addAssociation($newNode2, "cm_references");
// Save the changes made
$_ALF_SESSION->save();
// Check the node have the correct values after the save
assertEquals("changed.txt", $node->cm_name);
assertEquals("Mr Trouble", $node->cm_author);
assertTrue($node->hasAspect("cm_titled"));
assertFalse($node->hasAspect("cm_versionable"));
assertEquals("my title", $node->cm_title);
assertEquals("my description", $node->cm_description);
 /**
  * @param string $attribute
  * @param string $family
  * @param string $channel
  *
  * @Given /^attribute "([^"]*)" should be optional in family "([^"]*)" for channel "([^"]*)"$/
  */
 public function attributeShouldBeOptionalInFamilyForChannel($attribute, $family, $channel)
 {
     $requirement = $this->getAttributeRequirement($attribute, $family, $channel);
     assertNotNull($requirement);
     assertFalse($requirement->isRequired());
 }
示例#29
0
 public function test_ensure_interpret_removes_token()
 {
     $this->ScaffoldingManager->interpretInputData($this->input);
     assertFalse(isset($this->input['_token']));
     assertEquals($this->input['model_name'], 'Testing');
 }
示例#30
0
function testInvalidAddressesDoNotValidate()
{
    assertFalse(Bitcoin\isValidAddress('1abc'));
    assertFalse(Bitcoin\isValidAddress('1abcdefghijklmnopqrstuvwxyzABC1123XYZ'));
    assertFalse(Bitcoin\isValidAddress('[]'));
}