This repository has been archived by the owner on Dec 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed bug when unedited Document saved
- Loading branch information
1 parent
3a6a64c
commit 68c0472
Showing
5 changed files
with
64 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
return [ | ||
'default' => [ | ||
'name' => 'Document for edit', | ||
'number' => '1333-e', | ||
'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit....', | ||
'created_by' => 1, | ||
'created_at' => time(), | ||
'registered_at' => strtotime('2017-08-14'), | ||
'from' => 'Store', | ||
'to' => 'Office', | ||
'category' => 1, | ||
'type' => 1, | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace tracker\tests\unit; | ||
|
||
use tracker\models\Document; | ||
use tracker\models\DocumentFileEntity; | ||
use tracker\tests\fixtures\DocumentFixture; | ||
|
||
/** | ||
* @author Evgeniy Tkachenko <[email protected]> | ||
* @property \tracker\UnitTester tester | ||
*/ | ||
class DocumentFileEntityTest extends \Codeception\Test\Unit | ||
{ | ||
public function testMoveToNewCategory() | ||
{ | ||
$this->tester->haveFixtures([ | ||
'documents' => [ | ||
'class' => DocumentFixture::class, | ||
'dataFile' => '@tracker/tests/fixtures/data/documents.php' | ||
] | ||
]); | ||
|
||
/** @var Document $defaultDocument */ | ||
$defaultDocument = $this->tester->grabFixture('documents', 'default'); | ||
|
||
$file = new DocumentFileEntity($defaultDocument); | ||
|
||
$this->assertTrue($file->moveToNewCategory()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ function mkdir() | |
use tracker\models\Document; | ||
use tracker\models\DocumentFileEntity; | ||
use tracker\tests\fixtures\DocumentFileFixture; | ||
use tracker\tests\fixtures\DocumentFixture; | ||
|
||
/** | ||
* @author Evgeniy Tkachenko <[email protected]> | ||
|
@@ -145,38 +146,30 @@ public function testWorkWithCreator() | |
|
||
public function testWorkWithEditor() | ||
{ | ||
$defaultAttributes = [ | ||
'name' => 'Document for edit', | ||
'number' => '1333-e', | ||
'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit....', | ||
'created_by' => 1, | ||
'created_at' => time(), | ||
'registered_at' => strtotime('2017-08-14'), | ||
'from' => 'Store', | ||
'to' => 'Office', | ||
'category' => 1, | ||
'type' => 1, | ||
]; | ||
$this->tester->haveFixtures([ | ||
'documents' => [ | ||
'class' => DocumentFixture::class, | ||
'dataFile' => '@tracker/tests/fixtures/data/documents.php' | ||
] | ||
]); | ||
|
||
$this->tester->dontSeeRecord(Document::class, ['name' => $defaultAttributes['name']]); | ||
$this->tester->haveRecord(Document::class, $defaultAttributes); | ||
$this->tester->seeRecord(Document::class, ['name' => $defaultAttributes['name']]); | ||
/** @var Document $defaultDocument */ | ||
$defaultDocument = $this->tester->grabFixture('documents', 'default'); | ||
|
||
$defaultDocument = Document::find()->where(['name' => $defaultAttributes['name']])->one(); | ||
$documentEditor = new DocumentEditor($defaultDocument); | ||
|
||
$requestModel = $documentEditor->getDocumentForm(); | ||
|
||
$this->assertEquals($defaultAttributes['name'], $requestModel->name); | ||
$this->assertEquals($defaultAttributes['description'], $requestModel->description); | ||
$this->assertEquals($defaultAttributes['registered_at'], | ||
$this->assertEquals($defaultDocument['name'], $requestModel->name); | ||
$this->assertEquals($defaultDocument['description'], $requestModel->description); | ||
$this->assertEquals($defaultDocument['registered_at'], | ||
date_create_from_format('Y-m-d', $requestModel->registeredAt) | ||
->setTime(0, 0) | ||
->format('U')); | ||
$this->assertEquals($defaultAttributes['from'], $requestModel->from); | ||
$this->assertEquals($defaultAttributes['to'], $requestModel->to); | ||
$this->assertEquals($defaultAttributes['type'], $requestModel->type); | ||
$this->assertEquals($defaultAttributes['category'], $requestModel->category); | ||
$this->assertEquals($defaultDocument['from'], $requestModel->from); | ||
$this->assertEquals($defaultDocument['to'], $requestModel->to); | ||
$this->assertEquals($defaultDocument['type'], $requestModel->type); | ||
$this->assertEquals($defaultDocument['category'], $requestModel->category); | ||
|
||
$newAttributes = [ | ||
'name' => 'Document for edit 2', | ||
|