8 |
9 |
10 |
11 | ' . CropboxWidget::t('Browse');
13 | if ($hasModel) {
14 | echo Html::activeFileInput($this->context->model, $this->context->attribute, $this->context->options);
15 | } else {
16 | echo Html::fileInput($this->context->name, $this->context->value, $this->context->options);
17 | }
18 | ?>
19 |
20 |
21 | = Html::button(' ' . CropboxWidget::t('Crop'), [
22 | 'class' => 'btn btn-success btn-crop',
23 | ]); ?>
24 | = Html::button(' ' . CropboxWidget::t('Reset'), [
25 | 'class' => 'btn btn-warning btn-reset',
26 | ]); ?>
27 | = Html::button(' ', [
28 | 'class' => 'btn btn-default btn-scale-out',
29 | ]); ?>
30 | = Html::button(' ', [
31 | 'class' => 'btn btn-default btn-scale-in',
32 | ]); ?>
33 |
34 |
35 |
36 | context->originalImageUrl)) {
38 | echo Html::a(
39 | ' ' . CropboxWidget::t('Show original'),
40 | $this->context->originalImageUrl,
41 | [
42 | 'target' => '_blank',
43 | 'class' => 'btn btn-info',
44 | ]
45 | );
46 | }
47 | ?>
48 |
49 | context->croppedImagesUrl;
51 | foreach ($croppedImagesUrl as $url) {
52 | echo Html::img($url, ['class' => 'img-thumbnail']);
53 | }
54 | ?>
55 |
56 | context->model, $this->context->croppedDataAttribute);
59 | } else {
60 | echo Html::hiddenInput($this->context->croppedDataName, $this->context->croppedDataValue);
61 | }
62 | ?>
63 |
--------------------------------------------------------------------------------
/tests/functionals/CropboxTest.php:
--------------------------------------------------------------------------------
1 | mockApplication();
12 | $result = Yii::$app->runAction('cropbox/index');
13 | $this->assertNotEmpty($result);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/tests/functionals/TestCase.php:
--------------------------------------------------------------------------------
1 | destroyApplication();
16 | }
17 |
18 | /**
19 | * @param array $config
20 | */
21 | protected function mockApplication($config = [])
22 | {
23 | new Application(ArrayHelper::merge(require __DIR__ . '/assets/config/main.php', $config));
24 | }
25 |
26 | /**
27 | * Destroys application in Yii::$app by setting it to null.
28 | */
29 | protected function destroyApplication()
30 | {
31 | Yii::$app = null;
32 | Yii::$container = new Container;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/tests/functionals/assets/assets/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/tests/functionals/assets/config/main.php:
--------------------------------------------------------------------------------
1 | 'app-test',
5 | 'basePath' => __DIR__ . '/..',
6 | 'vendorPath' => __DIR__ . '/../../../../vendor',
7 | 'aliases' => [
8 | '@bupy7/cropbox' => __DIR__ . '/../../../../src',
9 | ],
10 | 'components' => [
11 | 'request' => [
12 | 'enableCsrfValidation' => false,
13 | 'cookieValidationKey' => 'wefJDF8sfdsfSDefwqdxj9oq',
14 | 'scriptFile' => __DIR__ . '/index.php',
15 | 'scriptUrl' => '/index.php',
16 | ],
17 | 'assetManager' => [
18 | 'basePath' => '@app/assets',
19 | 'baseUrl' => '/',
20 | ],
21 | ]
22 | ];
23 |
--------------------------------------------------------------------------------
/tests/functionals/assets/controllers/CropboxController.php:
--------------------------------------------------------------------------------
1 | render('index', [
17 | 'form' => $form,
18 | ]);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tests/functionals/assets/forms/CropboxForm.php:
--------------------------------------------------------------------------------
1 | ['jpg', 'jpeg', 'png', 'gif'],
25 | 'mimeTypes' => ['image/jpeg', 'image/pjpeg', 'image/png', 'image/gif'],
26 | ],
27 | ['crop_info', 'safe'],
28 | ];
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/tests/functionals/assets/views/cropbox/index.php:
--------------------------------------------------------------------------------
1 | ['enctype'=>'multipart/form-data'],
8 | 'action' => ['cropbox'],
9 | ]);
10 |
11 | echo $af->field($form, 'image')->widget(CropboxWidget::className(), [
12 | 'croppedDataAttribute' => 'crop_info',
13 | ]);
14 |
15 | ActiveForm::end();
16 |
--------------------------------------------------------------------------------
/tests/functionals/assets/views/layouts/main.php:
--------------------------------------------------------------------------------
1 | beginPage();
3 | $this->head();
4 | $this->beginBody();
5 | $this->endBody();
6 | $this->endPage();
7 |
--------------------------------------------------------------------------------
/tests/functionals/bootstrap.php:
--------------------------------------------------------------------------------
1 |