本文整理汇总了PHP中UnitTester类的典型用法代码示例。如果您正苦于以下问题:PHP UnitTester类的具体用法?PHP UnitTester怎么用?PHP UnitTester使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UnitTester类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUserAdd
public function testUserAdd()
{
$user = factory(User::class, 'valid-user')->make();
$values = ['first_name' => $user->first_name, 'last_name' => $user->last_name, 'email' => $user->email, 'username' => $user->username, 'password' => $user->password];
User::create($values);
$this->tester->seeRecord('users', $values);
}
示例2: testAssetAdd
public function testAssetAdd()
{
$company = factory(Company::class, 'company')->make();
$values = ['name' => $company->name];
Company::create($values);
$this->tester->seeRecord('companies', $values);
}
示例3: testAssetAdd
public function testAssetAdd()
{
$location = factory(Location::class, 'location')->make();
$values = ['name' => $location->name];
Location::create($values);
$this->tester->seeRecord('locations', $values);
}
示例4: testLostStatuslabelAdd
public function testLostStatuslabelAdd()
{
$statuslabel = factory(Statuslabel::class, 'lost')->make();
$values = ['name' => $statuslabel->name];
Statuslabel::create($values);
$this->tester->seeRecord('status_labels', $values);
}
示例5: testLiking
public function testLiking()
{
$idUser1 = 1;
$idUser2 = 2;
$idUser3 = 3;
$idUser4 = 4;
$photoidUser1 = 1;
$photoidUser2 = 4;
$photoidUser3 = 8;
$photoidUser4 = 11;
// User should be able to like photos they don't own
list($result_code, $result) = User::likePhoto($idUser1, $photoidUser2);
$this->assertEquals(200, $result_code);
$this->assertTrue($result['success'] == true);
$this->assertTrue($result['likes'] == true);
$this->tester->seeInDatabase('UserPhotoLikes', ['userid' => $idUser1, 'photoid' => $photoidUser2]);
// User should be able to unlike photos they don't own
list($result_code, $result) = User::likePhoto($idUser1, $photoidUser2);
$this->assertEquals(200, $result_code);
$this->assertTrue($result['success'] == true);
$this->assertTrue($result['likes'] == false);
$this->tester->dontSeeInDatabase('UserPhotoLikes', ['userid' => $idUser1, 'photoid' => $photoidUser2]);
// User should not be be able to like photos they own
list($result_code, $result) = User::likePhoto($idUser1, $photoidUser1);
$this->assertEquals(403, $result_code);
$this->assertTrue($result['success'] == false);
$this->tester->dontSeeInDatabase('UserPhotoLikes', ['userid' => $idUser1, 'photoid' => $photoidUser1]);
// User should not be be able to like photos that don't exist
list($result_code, $result) = User::likePhoto($idUser1, 0);
$this->assertEquals(404, $result_code);
$this->assertTrue($result['success'] == false);
$this->tester->dontSeeInDatabase('UserPhotoLikes', ['userid' => $idUser1, 'photoid' => 0]);
}
示例6: testRoleCanBeDeleted
public function testRoleCanBeDeleted()
{
$id = $this->tester->haveRecord('roles', ['role_name' => 'user']);
$role = \ChopBox\Role::find($id);
$role->delete();
$this->tester->dontSeeRecord('roles', ['role_name' => 'user']);
}
示例7: testConsumableAdd
public function testConsumableAdd()
{
$consumable = factory(Consumable::class, 'consumable')->make();
$values = ['name' => $consumable->name, 'qty' => $consumable->qty, 'category_id' => $consumable->category_id, 'company_id' => $consumable->company_id];
Consumable::create($values);
$this->tester->seeRecord('consumables', $values);
}
示例8: testAccessoryCategoryAdd
public function testAccessoryCategoryAdd()
{
$category = factory(Category::class, 'accessory-category')->make();
$values = ['name' => $category->name, 'category_type' => $category->category_type];
Category::create($values);
$this->tester->seeRecord('categories', $values);
}
示例9: testLostStatuslabelAdd
public function testLostStatuslabelAdd()
{
$statuslabel = factory(Statuslabel::class, 'lost')->make();
$values = ['name' => $statuslabel->name, 'deployable' => $statuslabel->deployable, 'pending' => $statuslabel->pending, 'archived' => $statuslabel->archived];
Statuslabel::create($values);
$this->tester->seeRecord('status_labels', $values);
}
示例10: testCreateWithoutFactory
public function testCreateWithoutFactory()
{
$factory = new \WebChemistry\Forms\Factory\Container();
$this->tester->assertExceptionThrown('WebChemistry\\Forms\\FormException', function () use($factory) {
$factory->create();
});
}
示例11: testAssetModelAdd
public function testAssetModelAdd()
{
$assetmodel = factory(AssetModel::class, 'assetmodel')->make();
$values = ['name' => $assetmodel->name, 'manufacturer_id' => $assetmodel->manufacturer_id, 'category_id' => $assetmodel->category_id, 'eol' => $assetmodel->eol];
AssetModel::create($values);
$this->tester->seeRecord('models', $values);
}
示例12: createPlantWithColorForTest
/**
* @return mixed
*/
public function createPlantWithColorForTest()
{
$plantID = $this->tester->haveRecord('plants', ['name' => 'test plant']);
$colorArray = array("red" => "red", "yellow" => "yellow", "blue" => NULL, "green" => NULL, "brown" => NULL, "black" => NULL, "white" => NULL, "purple" => NULL, "orange" => NULL);
$this->UUT->set($plantID, $colorArray);
return $plantID;
}
示例13: testWrongTimestamps
public function testWrongTimestamps()
{
foreach ($this->bad_timestamps as $bad) {
$this->modelWValidation->start_date = $bad;
$this->tester->assertFalse($this->modelWValidation->save());
}
}
示例14: testSetUnit
public function testSetUnit()
{
$metric = new Metric();
$this->tester->assertFalse($metric->setUnit('Invalid'), 'Metric::setUnit invalid unit set failed!');
$metric->setUnit('Kilobits/Second');
$this->tester->assertEquals('Kilobits/Second', $metric->getUnit(), 'Metric::setUnit failed!');
}
示例15: testSupplierAdd
public function testSupplierAdd()
{
$supplier = factory(Supplier::class, 'supplier')->make();
$values = ['name' => $supplier->name];
Supplier::create($values);
$this->tester->seeRecord('suppliers', $values);
}