コード例 #1
1
 public function testDifferentStopwatchesDoNotShareState()
 {
     $firstStopwatch = stopwatch();
     usleep(100);
     $secondStopwatch = stopwatch();
     assertThat($this->getElapsedSeconds($firstStopwatch), not($this->getElapsedSeconds($secondStopwatch)));
 }
 public function testTruncateCategoryAnalytics()
 {
     Factory::create('Giftertipster\\Entity\\Eloquent\\Analytic\\CategoryAnalytic');
     assertThat(CategoryAnalytic::get()->toArray(), not(emptyArray()));
     $this->repo->truncateCategoryAnalytics();
     assertThat(CategoryAnalytic::get()->toArray(), emptyArray());
 }
コード例 #3
0
 public function testEvaluatesToTrueIfArgumentIsReferenceToASpecifiedObject()
 {
     $o1 = new stdClass();
     $o2 = new stdClass();
     assertThat($o1, identicalTo($o1));
     assertThat($o2, not(identicalTo($o1)));
 }
コード例 #4
0
 public function testDelegatesMatchingToAnotherMatcher()
 {
     $m1 = describedAs('irrelevant', anything());
     $m2 = describedAs('irrelevant', not(anything()));
     $this->assertTrue($m1->matches(new \stdClass()));
     $this->assertFalse($m2->matches('hi'));
 }
コード例 #5
0
 public function testEvaluatesToTrueIfArgumentIsReferenceToASpecifiedObject()
 {
     $o1 = new \stdClass();
     $o2 = new \stdClass();
     assertThat($o1, sameInstance($o1));
     assertThat($o2, not(sameInstance($o1)));
 }
コード例 #6
0
ファイル: IsNullTest.php プロジェクト: zhangjingli35/hamcrest
 public function testEvaluatesToTrueIfArgumentIsNull()
 {
     assertThat(null, nullValue());
     assertThat(self::ANY_NON_NULL_ARGUMENT, not(nullValue()));
     assertThat(self::ANY_NON_NULL_ARGUMENT, notNullValue());
     assertThat(null, not(notNullValue()));
 }
コード例 #7
0
 function testGetTopLevelLicenseRefs()
 {
     $licenseMap = new LicenseMap($this->dbManager, $this->groupId, LicenseMap::CONCLUSION);
     $topLevelLicenses = $licenseMap->getTopLevelLicenseRefs();
     assertThat($topLevelLicenses, hasItemInArray(new LicenseRef(1, 'One', 'One-1')));
     assertThat($topLevelLicenses, not(hasKeyInArray(2)));
 }
コード例 #8
0
 public function testEvaluatesToFalseIfArgumentDoesntMatchType()
 {
     assertThat(false, not(numericValue()));
     assertThat('foo', not(numericValue()));
     assertThat('foo5', not(numericValue()));
     assertThat('5foo', not(numericValue()));
 }
コード例 #9
0
 public function testEvaluatesToFalseIfArgumentIsNotAnObject()
 {
     assertThat(null, not(anInstanceOf('Hamcrest_Core_SampleBaseClass')));
     assertThat(false, not(anInstanceOf('Hamcrest_Core_SampleBaseClass')));
     assertThat(5, not(anInstanceOf('Hamcrest_Core_SampleBaseClass')));
     assertThat('foo', not(anInstanceOf('Hamcrest_Core_SampleBaseClass')));
     assertThat(array(1, 2, 3), not(anInstanceOf('Hamcrest_Core_SampleBaseClass')));
 }
コード例 #10
0
 public function testEvaluatesToFalseIfArgumentDoesntMatchType()
 {
     assertThat(null, not(scalarValue()));
     assertThat(array(), not(scalarValue()));
     assertThat(array(5), not(scalarValue()));
     assertThat(tmpfile(), not(scalarValue()));
     assertThat(new \stdClass(), not(scalarValue()));
 }
コード例 #11
0
 public function testEvaluatesToFalseIfArgumentDoesntMatchType()
 {
     assertThat(false, not(typeOf('array')));
     assertThat(array('5', 5), not(typeOf('boolean')));
     assertThat(5.2, not(typeOf('integer')));
     assertThat(5, not(typeOf('double')));
     assertThat(false, not(typeOf('null')));
     assertThat('a string', not(typeOf('resource')));
     assertThat(tmpfile(), not(typeOf('string')));
 }
コード例 #12
0
 public function testRecursivelyTestsElementsOfArrays()
 {
     $i1 = array(array(1, 2), array(3, 4));
     $i2 = array(array(1, 2), array(3, 4));
     $i3 = array(array(5, 6), array(7, 8));
     $i4 = array(array(1, 2, 3, 4), array(3, 4));
     assertThat($i1, equalTo($i1));
     assertThat($i2, equalTo($i1));
     assertThat($i3, not(equalTo($i1)));
     assertThat($i4, not(equalTo($i1)));
 }
コード例 #13
0
 public function testFilterGalleryAttributesFromMetaFieldsWhenSaves()
 {
     $attributes = ['post_content' => 'Dummy Content.', 'post_title' => 'Dummy Title', 'post_date' => date('Y-m-d H:i:s'), 'pal_user_id' => 1, 'pal_gallery_id' => 1];
     $gallery = new Gallery($attributes);
     $gallery->save();
     $attributes = $gallery->getAttributes();
     assertThat($attributes, hasKey('post_content'));
     assertThat($attributes, hasKey('post_title'));
     assertThat($attributes, hasKey('post_date'));
     assertThat($attributes, not(hasKey('pal_user_id')));
     assertThat($attributes, not(hasKey('pal_gallery_id')));
 }
コード例 #14
0
 public function testEvaluatesToFalseIfArgumentDoesntMatchType()
 {
     assertThat(false, not(numericValue()));
     assertThat('foo', not(numericValue()));
     assertThat('foo5', not(numericValue()));
     assertThat('5foo', not(numericValue()));
     assertThat('0x42A04G', not(numericValue()));
     // G is not in the hexadecimal range.
     assertThat('1x42A04', not(numericValue()));
     // 1x is not a valid hexadecimal sequence.
     assertThat('0x', not(numericValue()));
 }
コード例 #15
0
ファイル: ApplicationTest.php プロジェクト: brtriver/dbup
 public function testGetStatuses()
 {
     $this->app->sqlFilesDir = __DIR__ . '/sql';
     $this->app->appliedFilesDir = __DIR__ . '/.dbup/applied';
     $statuses = $this->app->getStatuses();
     assertThat(count($statuses), is(3));
     assertThat($statuses[0]->appliedAt, is(not('')));
     assertThat($statuses[0]->file->getFileName(), is('V1__sample_select.sql'));
     assertThat($statuses[1]->appliedAt, is(''));
     assertThat($statuses[1]->file->getFileName(), is('V3__sample3_select.sql'));
     assertThat($statuses[2]->appliedAt, is(''));
     assertThat($statuses[2]->file->getFileName(), is('V12__sample12_select.sql'));
 }
 public function testGetUnfulfilledRequests()
 {
     Factory::create('Giftertipster\\Entity\\Eloquent\\User', ['permissions' => []]);
     Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
     Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
     $seed_request1 = Factory::create('Giftertipster\\Entity\\Eloquent\\ProductDeleteRequest', ['user_id' => 1, 'product_id' => 1, 'is_fulfilled' => 1, 'delete_type' => 'delete']);
     $seed_request2 = Factory::create('Giftertipster\\Entity\\Eloquent\\ProductDeleteRequest', ['user_id' => 1, 'product_id' => 2, 'is_fulfilled' => 0, 'delete_type' => 'delete']);
     $repo = $this->app->make('Giftertipster\\Repository\\ProductDeleteRequest\\EloquentProductDeleteRequestRepository');
     $requests = $repo->getUnfulfilledRequests();
     assertThat($requests, not(emptyArray()));
     assertThat($requests[0], hasKeyValuePair('id', 2));
     assertThat($requests[0], hasKeyValuePair('is_fulfilled', 0));
 }
 public function testSubProductForCartAddWorks()
 {
     $sub_product = Factory::create('Giftertipster\\Entity\\Eloquent\\SubProduct', ['id' => 1, 'vendor_id' => 'asin stub', 'offer_listing_id' => 'offer listing id stub']);
     $image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['category' => 'variation']);
     $image2 = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['category' => 'primary']);
     $sub_product->images()->save($image);
     $sub_product->images()->save($image2);
     $sub_product2 = Factory::create('Giftertipster\\Entity\\Eloquent\\SubProduct');
     $sub_product_repo = $this->app->make('Giftertipster\\Repository\\SubProduct\\EloquentSubProductRepository');
     $result_sub_product = $sub_product_repo->subProductDataForCartAdd(1);
     assertThat($result_sub_product, hasKeyValuePair('id', 1));
     assertThat($result_sub_product, hasKey('images'));
     assertThat($result_sub_product['images'], not(emptyArray()));
 }
コード例 #18
0
ファイル: Faker.php プロジェクト: grrr-amsterdam/garp3
 /**
  * Create a row with fake values
  *
  * @param array $fieldConfiguration As taken from Garp_Model_Db::getConfiguration()
  * @param array $defaultValues      Any values you want to provide yourself
  * @return array
  */
 public function createFakeRow(array $fieldConfiguration, array $defaultValues = array())
 {
     $out = array();
     // TODO for now, filter primary keys, assuming they will be auto-generated by the database
     $fieldConfiguration = array_filter($fieldConfiguration, not(array_get('primary')));
     foreach ($fieldConfiguration as $field) {
         $fieldName = $field['name'];
         if (array_key_exists($fieldName, $defaultValues)) {
             $out[$fieldName] = $defaultValues[$fieldName];
             continue;
         }
         $out[$fieldName] = $this->getFakeValueForField($field);
     }
     return $out;
 }
コード例 #19
0
ファイル: Models.php プロジェクト: grrr-amsterdam/garp3
 /**
  * Interactively insert a new record
  *
  * @param array $args
  * @return bool
  */
 public function insert($args)
 {
     if (empty($args)) {
         Garp_Cli::errorOut('Please provide a model');
         return false;
     }
     $className = "Model_{$args[0]}";
     $model = new $className();
     $fields = $model->getConfiguration('fields');
     $fields = array_filter($fields, not(propertyEquals('name', 'id')));
     $mode = $this->_getInsertionMode();
     if ($mode === 'g') {
         $newData = $this->_createGibberish($fields);
     } else {
         $newData = array_reduce($fields, function ($acc, $cur) {
             $acc[$cur['name']] = Garp_Cli::prompt($cur['name']) ?: null;
             return $acc;
         }, array());
     }
     $id = $model->insert($newData);
     Garp_Cli::lineOut("Record created: #{$id}");
     return true;
 }
コード例 #20
0
 public function testEvaluatesToFalseIfArgumentDoesntMatchType()
 {
     assertThat(array(), not(booleanValue()));
     assertThat(5, not(booleanValue()));
     assertThat('foo', not(booleanValue()));
 }
コード例 #21
0
ファイル: AllOfTest.php プロジェクト: ngitimfoyo/Nyari-AppPHP
 public function testSupportsMixedTypes()
 {
     $all = allOf(equalTo(new \Hamcrest\Core\SampleBaseClass('good')), equalTo(new \Hamcrest\Core\SampleBaseClass('good')), equalTo(new \Hamcrest\Core\SampleSubClass('ugly')));
     $negated = not($all);
     assertThat(new \Hamcrest\Core\SampleSubClass('good'), $negated);
 }
コード例 #22
0
 public function testIsTrueWhenEveryValueMatches()
 {
     assertThat(array('AaA', 'BaB', 'CaC'), everyItem(containsString('a')));
     assertThat(array('AbA', 'BbB', 'CbC'), not(everyItem(containsString('a'))));
 }
コード例 #23
0
ファイル: HasXPathTest.php プロジェクト: Comforse/laratracker
 public function testDoesNotMatchWhenContentDoesNotMatch()
 {
     assertThat('no match', self::$doc, not(hasXPath('user/name', containsString('Bobby'))));
     assertThat('no matches', self::$doc, not(hasXPath('user/role', equalTo('owner'))));
 }
 public function testMltSearchReturnsFalseWithErrorsAvailableWhenSearchOperationIsNotSuccessful()
 {
     $es_mock = Mockery::mock('Elasticsearch\\Client');
     $es_mock->shouldReceive('mlt')->once()->andReturn(['error' => 'error test', 'status' => 400]);
     $this->app->instance('Elasticsearch\\Client', $es_mock);
     $repo = $this->getRepo();
     $response = $repo->mltSearch('test query', 100);
     $errors = $repo->errors();
     assertThat($response, identicalTo(false));
     assertThat($errors, not(isEmptyString()));
 }
コード例 #25
0
ファイル: SetTest.php プロジェクト: ngitimfoyo/Nyari-AppPHP
 public function testEvaluatesToFalseIfObjectPropertyIsNotSet()
 {
     assertThat($this, not(set('_instanceProperty')));
 }
 public function testAddPopularitySearchReturnsResultOnSuccess()
 {
     //product
     $this->client->index(['index' => $this->product_index, 'type' => $this->product_type, 'id' => 100, 'body' => ['title' => 'test product', 'min_price' => 20000, 'max_price' => 20000, 'datetime' => '2014-02-14 00:01:01', 'group' => 'testgroup1', 'soft_delete_status' => 0], 'refresh' => true]);
     //product
     $this->client->index(['index' => $this->product_index, 'type' => $this->product_type, 'id' => 200, 'body' => ['title' => 'test product2', 'min_price' => 30000, 'max_price' => 20000, 'datetime' => '2014-02-14 00:01:01', 'group' => 'testgroup2', 'soft_delete_status' => 0], 'refresh' => true]);
     //add
     $this->client->index(['index' => $this->add_index, 'type' => $this->add_type, 'id' => 1, 'parent' => 100, 'body' => ['gender_ids' => 1, 'interest_ids' => [1, 2], 'datetime' => '2014-02-14 00:01:01'], 'refresh' => true]);
     //add
     $this->client->index(['index' => $this->add_index, 'type' => $this->add_type, 'id' => 2, 'parent' => 100, 'body' => ['gender_ids' => 2, 'interest_ids' => [2], 'datetime' => '2014-02-14 00:01:01'], 'refresh' => true]);
     //add
     $this->client->index(['index' => $this->add_index, 'type' => $this->add_type, 'id' => 3, 'parent' => 200, 'body' => ['gender_ids' => 1, 'interests\\_ids' => [2], 'datetime' => '2014-02-14 00:01:01'], 'refresh' => true]);
     $result = $this->repo->AddPopularitySearch(0, 100);
     assertThat($result, hasKey('results'));
     assertThat($result['results'], not(emptyArray()));
     assertThat($result['results'][0], not(hasKey('_source')));
     assertThat($result['meta']['total_hits'], atLeast(1));
     assertThat($result, hasKey('facets'));
     assertThat($result['facets'], hasKey('price'));
     assertThat($result['facets']['price'], not(emptyArray()));
     assertThat($result['facets'], hasKey('group'));
 }
コード例 #27
0
 public function testEvaluatesToFalseIfArgumentDoesntMatchRegex()
 {
     assertThat('foobar', not(matchesPattern('/^foob$/')));
     assertThat('foobar', not(matchesPattern('/oobe/')));
 }
コード例 #28
0
ファイル: misc.php プロジェクト: Vinceveve/php-rql
 public function not()
 {
     return not($this);
 }
コード例 #29
0
 public function testEvaluatesToFalseIfArgumentDoesntMatchType()
 {
     assertThat(false, not(integerValue()));
     assertThat(5.2, not(integerValue()));
     assertThat('foo', not(integerValue()));
 }
コード例 #30
0
 public function testEvaluatesToFalseIfArgumentDoesntMatchType()
 {
     assertThat(false, not(callableValue()));
     assertThat(5.2, not(callableValue()));
 }